* {
    box-sizing: border-box;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

body {
    background: #07070b;
    color: #a0a0b0;
    font-family: 'Courier New', monospace;
    margin: 0;
    min-height: 100vh;
    padding: 16px;
}

#arcade-shell {
    width: min(100%, 1180px);
    margin: 0 auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #0b0b10;
    border: 2px solid #232334;
    border-radius: 8px;
}

.control-header,
.tab-menu {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.control-header {
    border-bottom: 1px solid #232334;
    padding-bottom: 10px;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.system-status {
    color: #29abe2;
    font-size: 15px;
    font-weight: bold;
}

.action-btn,
#fullscreen-btn {
    background: #151522;
    border: 1px solid #34344e;
    border-radius: 4px;
    color: #fff;
    cursor: pointer;
    font: bold 14px monospace;
    padding: 10px 16px;
    text-transform: uppercase;
}

.action-btn:hover,
#fullscreen-btn:hover {
    background: #23233a;
    border-color: #29abe2;
    color: #29abe2;
}

.viewport-matrix {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.screen-box,
.console-hud {
    width: 100%;
}

canvas {
    display: block;
    width: 100%;
    height: auto;
    min-height: 360px;
    aspect-ratio: 16 / 9;
    background: #000;
    border: 3px solid #1a1a26;
    border-radius: 4px;
    image-rendering: pixelated;
}

.console-hud {
    background: #06060a;
    border: 1px solid #1a1a26;
    border-radius: 4px;
}

.tab-menu {
    border-bottom: 1px solid #1a1a26;
    background: #11111a;
}

.tab-link {
    flex: 1;
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font: bold 14px monospace;
    padding: 12px;
}

.tab-link.active {
    background: #101018;
    color: #29abe2;
}

.tab-content {
    display: none;
    min-height: 86px;
    overflow-y: auto;
    padding: 14px;
    font-size: 14px;
}

.tab-content.active-content {
    display: block;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    line-height: 1.8;
}

.item-list {
    color: #fff;
    line-height: 1.8;
    margin: 0;
    padding-left: 20px;
}

.dashboard-hud {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.party-slot {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    background: #11111a;
    border: 1px solid #1e1e2f;
    border-radius: 4px;
    padding: 10px;
    text-align: left;
    font: inherit;
}

.party-slot.selected,
.party-slot:focus-visible {
    border-color: #29abe2;
    outline: 2px solid #29abe2;
    outline-offset: 1px;
}

.party-portrait {
    width: 72px;
    height: 72px;
    flex: 0 0 auto;
    background: #000;
    image-rendering: pixelated;
    object-fit: cover;
}

.slot-info {
    flex: 1;
    min-width: 0;
}

.slot-name {
    overflow: hidden;
    color: #fff;
    font-size: 14px;
    font-weight: bold;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hp-track {
    height: 8px;
    margin-top: 8px;
    background: #272733;
}

.hp-fill {
    height: 100%;
    background: #35e512;
}

#spell-effect {
    display: none;
}

.spell-sprite:not(#spell-effect) {
    display: none;
}

.mobile-pad-container {
    display: flex;
    justify-content: center;
    padding: 18px 0 8px;
}

.combat-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.combat-actions > strong,
.auto-toggle {
    grid-column: 1 / -1;
}

.auto-toggle {
    color: #d5d7e4;
    font-size: 14px;
}

.recruit-panel {
    display: grid;
    gap: 10px;
    background: #101018;
    border: 1px solid #2b2b41;
    border-radius: 5px;
    color: #fff;
    padding: 14px;
}

.recruit-panel[hidden] {
    display: none;
}

.recruit-panel > span {
    color: #a0a0b0;
    font-size: 13px;
}

.recruit-row {
    display: grid;
    grid-template-columns: 1fr 1.4fr 1fr;
    gap: 8px;
    align-items: center;
}

.recruit-row select {
    min-height: 38px;
    background: #1c1c2a;
    border: 1px solid #34344e;
    border-radius: 3px;
    color: #fff;
    font: 14px monospace;
    padding: 6px;
}

.combat-actions[hidden] {
    display: none;
}

.interaction-actions[hidden] {
    display: none;
}

.combat-btn {
    min-height: 52px;
    background: #291b26;
    border: 2px solid #9d4052;
    border-radius: 5px;
    color: #fff;
    cursor: pointer;
    font: bold 15px monospace;
    padding: 10px;
}

.party-detail-panel,
.interaction-actions,
.event-log-panel {
    display: grid;
    gap: 10px;
    background: #101018;
    border: 1px solid #2b2b41;
    border-radius: 5px;
    color: #fff;
    padding: 14px;
}

.party-detail-panel[hidden],
.utility-actions,
.target-actions[hidden] {
    display: none;
}

.party-detail-panel {
    position: relative;
}

.panel-close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #1c1c2a;
    border: 1px solid #586174;
    border-radius: 3px;
    color: #fff;
    cursor: pointer;
    padding: 6px 10px;
}

.utility-actions {
    display: flex;
    gap: 10px;
}

.target-actions {
    display: grid;
    gap: 10px;
    background: #101018;
    border: 1px solid #2b2b41;
    border-radius: 5px;
    color: #fff;
    padding: 14px;
}

#target-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.target-btn {
    min-height: 44px;
    background: #1c1c2a;
    border: 2px solid #586174;
    border-radius: 4px;
    color: #fff;
    cursor: pointer;
    font: bold 14px monospace;
    padding: 8px 12px;
}

.target-btn.selected {
    border-color: #f0c674;
    background: #453a24;
}

.event-log-panel {
    color: #d5d7e4;
    font-size: 13px;
}

.event-log-panel > div {
    max-height: 110px;
    overflow-y: auto;
    white-space: pre-wrap;
}

.party-detail-panel span,
.interaction-actions span {
    display: block;
    color: #a0a0b0;
    font-size: 13px;
    margin-top: 4px;
}

.party-detail-stats,
.party-detail-abilities,
.shared-inventory {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    color: #d5d7e4;
    font-size: 13px;
}

.equipment-map {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    color: #d5d7e4;
    font-size: 13px;
}

.equipment-map .equipment-center {
    grid-column: 2;
    text-align: center;
}

.equipment-map .equipment-left {
    grid-column: 1;
    text-align: right;
}

.equipment-map .equipment-right {
    grid-column: 3;
}

.detail-chip {
    background: #1c1c2a;
    border: 1px solid #34344e;
    border-radius: 3px;
    padding: 6px 8px;
}

.inventory-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.inventory-item button {
    background: #263b48;
    border: 1px solid #29abe2;
    border-radius: 3px;
    color: #fff;
    cursor: pointer;
    padding: 5px 8px;
}

.interaction-actions > div {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.interaction-actions .combat-btn {
    min-height: 40px;
    padding: 8px 12px;
}

.combat-btn:hover,
.combat-btn:focus-visible {
    background: #9d4052;
    outline: 2px solid #f0c674;
    outline-offset: 2px;
}

.combat-btn:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

#reset-btn {
    border-color: #586174;
    background: #18202b;
}

.d-pad {
    position: relative;
    width: 210px;
    height: 190px;
}

.pad-btn {
    position: absolute;
    width: 62px;
    height: 62px;
    background: #151522;
    border: 2px solid #34344e;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 25px;
    touch-action: none;
}

.pad-btn:active {
    background: #29abe2;
    border-color: #fff;
    color: #000;
}

#touch-w { top: 0; left: 74px; }
#touch-a { top: 64px; left: 10px; }
#touch-d { top: 64px; right: 10px; }
#touch-s { bottom: 0; left: 74px; }
#touch-turn-left { top: 64px; left: -64px; }
#touch-turn-right { top: 64px; right: -64px; }

@media (max-width: 760px) {
    body { padding: 8px; }
    #arcade-shell { padding: 10px; }
    canvas { min-height: 0; }
    .dashboard-hud { grid-template-columns: repeat(2, 1fr); }
    .party-portrait { width: 56px; height: 56px; }
}

@media (max-width: 440px) {
    .dashboard-hud { grid-template-columns: 1fr; }
    .system-status { font-size: 12px; }
    .action-btn, #fullscreen-btn { font-size: 11px; padding: 8px 10px; }
    .combat-actions { grid-template-columns: repeat(2, 1fr); }
    .recruit-row { grid-template-columns: 1fr; }
}
