* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: #000;
    overflow: hidden;
}

#game-container {
    position: relative;
    width: 100vw;
    height: var(--app-height, 100vh);
    min-height: var(--app-height, 100vh);
    background-color: #000;
    overflow: hidden;
    isolation: isolate;
}

#game-container::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at center, transparent 34%, rgba(0, 0, 0, 0.08) 62%, rgba(0, 0, 0, 0.48) 100%);
    opacity: 0;
    pointer-events: none;
    z-index: 12;
    transition: opacity 0.35s ease;
}

#game-container.victory-focus::before {
    opacity: 1;
}

#game-container::after {
    content: "";
    position: absolute;
    inset: 10px;
    border-radius: 22px;
    border: 4px solid transparent;
    box-shadow: 0 0 0 rgba(0, 0, 0, 0);
    opacity: 0;
    pointer-events: none;
    z-index: 14;
    transition: opacity 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

#game-container.turn-local::after {
    opacity: 1;
    border-width: 6px;
    border-color: rgba(255, 92, 92, 0.98);
    box-shadow: 0 0 30px rgba(255, 72, 72, 0.58), inset 0 0 28px rgba(255, 72, 72, 0.18);
    animation: turnPulseLocal 0.72s ease-in-out infinite;
}

#game-container.turn-waiting::after {
    opacity: 1;
    border-color: rgba(110, 192, 255, 0.88);
    box-shadow: 0 0 20px rgba(61, 141, 255, 0.34), inset 0 0 18px rgba(61, 141, 255, 0.12);
    animation: turnPulseWaiting 1.4s ease-in-out infinite;
}

#game-container.turn-paused::after {
    opacity: 1;
    border-color: rgba(255, 199, 94, 0.92);
    box-shadow: 0 0 24px rgba(255, 179, 69, 0.4), inset 0 0 24px rgba(255, 179, 69, 0.16);
    animation: turnPulsePaused 0.9s ease-in-out infinite;
}

#game-container.turn-resolving::after {
    opacity: 1;
    border-color: rgba(255, 141, 94, 0.92);
    box-shadow: 0 0 22px rgba(255, 111, 0, 0.38), inset 0 0 20px rgba(255, 111, 0, 0.14);
    animation: turnPulseResolving 1.15s ease-in-out infinite;
}

#game-canvas {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    transform: translate(-50%, -50%);
    border-radius: 18px;
    background-color: #87CEEB; /* Sky blue */
    transition: box-shadow 0.2s ease, filter 0.2s ease;
}

#game-canvas.turn-local {
    box-shadow:
        0 0 0 6px rgba(255, 82, 82, 0.94),
        0 0 34px rgba(255, 72, 72, 0.48);
    animation: canvasTurnPulse 0.72s ease-in-out infinite;
}

/* UI Styles */
#ui-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 10px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.in-game-gameover {
    position: absolute;
    inset: 0;
    z-index: 18;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: max(28px, env(safe-area-inset-top)) 24px max(28px, calc(env(safe-area-inset-bottom) + 18px));
    pointer-events: none;
}

.in-game-gameover-copy {
    margin-top: 8vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
    color: #f9fbff;
    text-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
}

.in-game-gameover-title {
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    font-size: clamp(2.2rem, 6vw, 5rem);
    font-weight: bold;
    letter-spacing: 0.18em;
    color: #ffe37d;
}

.in-game-gameover-name {
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    font-size: clamp(1.3rem, 3vw, 2.4rem);
    letter-spacing: 0.06em;
}

.in-game-gameover-subtitle {
    color: rgba(241, 246, 255, 0.76);
    font-size: clamp(0.9rem, 1.6vw, 1.12rem);
    letter-spacing: 0.04em;
}

#return-to-lobby-btn {
    pointer-events: auto;
    min-width: 176px;
    min-height: 54px;
    padding: 12px 22px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(189, 205, 227, 0.82));
    color: #121821;
    font-size: 1rem;
    font-weight: bold;
    box-shadow: 0 18px 32px rgba(0, 0, 0, 0.26);
}

#return-to-lobby-btn:hover {
    filter: brightness(1.03);
    transform: translateY(-1px);
}

.turn-banner {
    --banner-accent: rgba(176, 201, 255, 0.88);
    position: absolute;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: min(84vw, 340px);
    max-width: min(92vw, 520px);
    overflow: hidden;
    padding: 9px 14px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-left: 4px solid var(--banner-accent);
    background: rgba(8, 14, 24, 0.82);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.26);
    color: white;
    text-align: left;
    z-index: 15;
    pointer-events: none;
}

.turn-banner::before {
    content: "";
    position: absolute;
    top: 0;
    left: 14px;
    right: 14px;
    height: 1px;
    background: linear-gradient(90deg, var(--banner-accent), rgba(176, 201, 255, 0));
    opacity: 0.72;
}

.turn-banner-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    font-size: 0.68rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.68);
}

.turn-banner-message {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1 1 auto;
    font-size: 1rem;
    font-weight: bold;
    letter-spacing: 0.02em;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
}

.turn-banner-copy {
    display: inline-block;
    min-width: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.9);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.turn-banner-count {
    display: inline-block;
    flex: 0 0 auto;
    margin-left: 0;
    font-size: 1.22rem;
    font-weight: 900;
    letter-spacing: 0.01em;
    color: #ffffff;
    text-shadow: 0 0 16px rgba(255, 255, 255, 0.18);
}

.turn-banner-sub {
    display: inline-block;
    min-width: 0;
    margin-left: 0;
    font-size: 0.84rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.72);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.turn-banner.turn-local {
    --banner-accent: rgba(255, 98, 98, 0.96);
    background: rgba(48, 10, 10, 0.88);
    box-shadow: 0 16px 34px rgba(104, 20, 20, 0.36);
    animation: hudTurnFlash 0.72s ease-in-out infinite;
}

.turn-banner.turn-waiting {
    --banner-accent: rgba(110, 192, 255, 0.9);
    background: rgba(10, 19, 34, 0.82);
}

.turn-banner.turn-paused {
    --banner-accent: rgba(255, 199, 94, 0.92);
    background: rgba(42, 27, 8, 0.82);
}

.turn-banner.turn-resolving {
    --banner-accent: rgba(255, 141, 94, 0.92);
    background: rgba(42, 17, 8, 0.82);
}

.combat-event {
    position: absolute;
    top: 92px;
    left: 50%;
    transform: translateX(-50%);
    min-width: min(72vw, 260px);
    max-width: min(86vw, 360px);
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(7, 11, 18, 0.82);
    color: #f4f7fb;
    font-size: 0.84rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-align: center;
    z-index: 15;
    pointer-events: none;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2);
}

.combat-event.tone-select {
    border-color: rgba(130, 203, 255, 0.36);
    color: #dff3ff;
}

.combat-event.tone-fire {
    border-color: rgba(255, 168, 127, 0.4);
    color: #ffe5d5;
}

.combat-event.tone-jam {
    border-color: rgba(120, 214, 255, 0.48);
    color: #dcf5ff;
    background: rgba(8, 19, 31, 0.88);
    box-shadow: 0 0 0 1px rgba(116, 216, 255, 0.12), 0 12px 28px rgba(28, 121, 173, 0.28);
}

.combat-event.tone-poison {
    border-color: rgba(122, 255, 149, 0.42);
    color: #e7ffe9;
    background: rgba(10, 22, 10, 0.88);
    box-shadow: 0 0 0 1px rgba(124, 255, 144, 0.1), 0 12px 28px rgba(30, 117, 58, 0.26);
}

#player-controls {
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 8px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    color: white;
    margin-bottom: 5px;
    width: 100%;
    max-width: 500px;
    touch-action: manipulation;
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.24);
    pointer-events: auto;
}

.control-row {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 5px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.9rem;
}

.control-group label {
    min-width: 80px;
}

.control-group input {
    flex: 1;
}

#power-container {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
}

.power-control-header,
.power-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.power-title {
    font-size: 0.72rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: #9cd2ff;
}

.power-readout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 68px;
    padding: 4px 10px;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(61, 141, 255, 0.18), rgba(255, 173, 94, 0.2));
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: #f7fbff;
    font-size: 1rem;
    font-weight: bold;
}

.power-meter {
    position: relative;
    height: 18px;
    overflow: hidden;
    border-radius: 6px;
    background: linear-gradient(90deg, rgba(28, 45, 68, 0.92), rgba(50, 32, 18, 0.92));
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.28);
}

.power-meter-ghost {
    position: absolute;
    inset: 0 auto 0 0;
    z-index: 2;
    width: 0;
    border-radius: 4px;
    background: linear-gradient(90deg, rgba(168, 209, 255, 0.22), rgba(255, 231, 168, 0.18));
    box-shadow: 0 0 12px rgba(166, 206, 255, 0.1);
    opacity: 0;
    transition: opacity 0.12s ease;
    pointer-events: none;
}

.power-meter-ghost::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 2px;
    height: 100%;
    background: rgba(226, 242, 255, 0.82);
    box-shadow: 0 0 10px rgba(180, 221, 255, 0.24);
}

.power-meter-fill {
    position: relative;
    z-index: 1;
    width: 20%;
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, #4ddf84, #ffd053);
    box-shadow: 0 0 16px rgba(255, 201, 83, 0.28);
    transition: width 0.05s linear, background 0.16s ease, box-shadow 0.16s ease;
}

.power-meter-grid {
    position: absolute;
    inset: 0;
    z-index: 3;
    background-image: linear-gradient(90deg, rgba(255, 255, 255, 0.18) 0 1px, transparent 1px 100%);
    background-size: 10% 100%;
    opacity: 0.45;
    pointer-events: none;
}

.power-meta {
    font-size: 0.74rem;
    color: rgba(255, 255, 255, 0.72);
}

.power-hint {
    color: rgba(255, 255, 255, 0.58);
}

.power-last strong {
    color: #fff2c8;
    font-size: 0.88rem;
}

.sr-only-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    pointer-events: none;
}

.angle-control-group {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
}

.angle-control-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.angle-title {
    font-size: 0.72rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: #f8d79a;
}

.angle-readout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 64px;
    padding: 4px 10px;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(110, 209, 192, 0.18), rgba(211, 154, 63, 0.22));
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: #fff7e4;
    font-size: 1rem;
    font-weight: bold;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.angle-dial {
    --angle-deg: 45;
    position: relative;
    width: 100%;
    max-width: 220px;
    height: 128px;
    margin: 0 auto;
    cursor: crosshair;
    touch-action: none;
    user-select: none;
    outline: none;
}

.angle-dial-face {
    position: absolute;
    left: 10px;
    right: 10px;
    top: 8px;
    bottom: 18px;
    border-radius: 220px 220px 0 0;
    border: 2px solid rgba(250, 230, 189, 0.46);
    border-bottom: none;
    background:
        radial-gradient(circle at 50% 100%, rgba(110, 209, 192, 0.26), rgba(110, 209, 192, 0.04) 40%, transparent 42%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.02));
    box-shadow:
        inset 0 16px 28px rgba(255, 255, 255, 0.04),
        inset 0 -14px 18px rgba(0, 0, 0, 0.28),
        0 10px 20px rgba(0, 0, 0, 0.16);
}

.angle-dial.active .angle-dial-face,
.angle-dial:focus-visible .angle-dial-face {
    border-color: rgba(110, 209, 192, 0.92);
    box-shadow:
        inset 0 16px 28px rgba(255, 255, 255, 0.06),
        inset 0 -14px 18px rgba(0, 0, 0, 0.22),
        0 0 0 3px rgba(110, 209, 192, 0.16),
        0 12px 24px rgba(0, 0, 0, 0.2);
}

.angle-dial-ticks {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.angle-tick {
    --tick-angle: 0;
    position: absolute;
    left: 50%;
    bottom: 18px;
    width: 0;
    height: 0;
    transform-origin: 0 0;
    transform: rotate(calc(var(--tick-angle) * -1deg));
}

.angle-tick::before {
    content: "";
    position: absolute;
    left: 74px;
    top: -1px;
    width: 6px;
    height: 2px;
    border-radius: 999px;
    background: rgba(255, 247, 228, 0.4);
}

.angle-tick.medium::before {
    width: 10px;
    background: rgba(255, 247, 228, 0.56);
}

.angle-tick.major::before {
    width: 14px;
    background: rgba(211, 154, 63, 0.95);
}

.angle-tick span {
    position: absolute;
    left: 103px;
    top: -8px;
    transform: translate(-50%, -50%) rotate(calc(var(--tick-angle) * 1deg));
    transform-origin: center;
    font-size: 11px;
    white-space: nowrap;
    color: #fff0ca;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.angle-dial-base {
    position: absolute;
    left: 18px;
    right: 18px;
    bottom: 18px;
    height: 4px;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(211, 154, 63, 0.9), rgba(247, 241, 232, 0.96), rgba(211, 154, 63, 0.9));
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.angle-needle {
    position: absolute;
    left: 50%;
    bottom: 18px;
    width: 90px;
    height: 4px;
    border-radius: 999px;
    transform-origin: 0 50%;
    transform: rotate(calc(var(--angle-deg) * -1deg));
    background: linear-gradient(90deg, #6ed1c0 0%, #d7fff8 58%, #f1b651 100%);
    box-shadow: 0 0 12px rgba(110, 209, 192, 0.4);
    pointer-events: none;
}

.angle-needle::after {
    content: "";
    position: absolute;
    right: -8px;
    top: 50%;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    transform: translate(50%, -50%);
    background: #fff6e0;
    border: 2px solid #17342c;
    box-shadow: 0 0 0 2px rgba(211, 154, 63, 0.9);
}

.angle-origin {
    position: absolute;
    left: 50%;
    bottom: 10px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    transform: translateX(-50%);
    background: #17342c;
    border: 4px solid #fff6e0;
    box-shadow: 0 0 0 2px rgba(110, 209, 192, 0.6);
    pointer-events: none;
}

.action-buttons {
    display: flex;
    justify-content: space-between;
    gap: 5px;
    margin-top: 5px;
    padding: 0;
}

.action-buttons button {
    flex: 1;
    min-height: 44px;
    padding: 8px 10px;
    border: none;
    border-radius: 4px;
    background-color: #4CAF50;
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 0.9rem;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.action-buttons button:hover:not(:disabled) {
    background-color: #3e8e41;
}

.action-buttons button:disabled {
    background-color: #868686;
    cursor: not-allowed;
}

.move-action-btn {
    position: relative;
    border: 1px solid rgba(173, 221, 255, 0.28);
    background: linear-gradient(180deg, #2f87d8, #175eae);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 8px 18px rgba(8, 44, 84, 0.24);
}

.move-action-btn:hover:not(:disabled) {
    background: linear-gradient(180deg, #45a0f1, #1c71cb);
}

.move-action-left {
    clip-path: polygon(18% 0, 100% 0, 100% 100%, 18% 100%, 0 50%);
    padding-left: 18px;
}

.move-action-right {
    clip-path: polygon(0 0, 82% 0, 100% 50%, 82% 100%, 0 100%);
    padding-right: 18px;
}

.move-action-icon {
    font-size: 1rem;
    line-height: 1;
}

.move-action-label {
    font-size: 0.74rem;
    font-weight: bold;
}

#fire-btn {
    flex: 0 0 auto;
    width: clamp(64px, 16vw, 84px);
    min-width: clamp(64px, 16vw, 84px);
    min-height: clamp(64px, 16vw, 84px);
    padding: 10px 8px;
    border-radius: 50%;
    border: 2px solid rgba(255, 212, 185, 0.34);
    background: radial-gradient(circle at 35% 30%, #ffcfb4 0%, #ff9b69 20%, #ef4333 48%, #b70f0f 74%, #660404 100%);
    box-shadow:
        inset 0 2px 10px rgba(255, 255, 255, 0.14),
        inset 0 -10px 16px rgba(90, 0, 0, 0.28),
        0 12px 26px rgba(120, 10, 10, 0.3);
    flex-direction: column;
    gap: 5px;
    letter-spacing: 0.14em;
}

#fire-btn .fire-action-core {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: radial-gradient(circle, #fff7b0 0%, #ffd768 38%, #ff8f38 70%, #9d0909 100%);
    box-shadow: 0 0 10px rgba(255, 208, 104, 0.4);
}

#fire-btn .fire-action-label {
    font-size: 0.7rem;
    font-weight: 900;
}

#fire-btn:hover:not(:disabled) {
    background: radial-gradient(circle at 35% 30%, #ffe0c4 0%, #ffb57f 22%, #ff5f43 48%, #d01515 74%, #770606 100%);
}

#fire-btn:disabled {
    background: radial-gradient(circle at 35% 30%, #92807a 0%, #6d5753 24%, #544241 55%, #3a2d2d 100%);
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: inset 0 2px 8px rgba(255, 255, 255, 0.08), 0 8px 16px rgba(0, 0, 0, 0.18);
}

#fire-btn:disabled .fire-action-core {
    background: radial-gradient(circle, #d1ccc6 0%, #938a84 55%, #5a4f4c 100%);
    box-shadow: none;
}

.move-action-btn:disabled {
    border-color: rgba(255, 255, 255, 0.12);
    background: linear-gradient(180deg, #667381, #4f5b67);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 8px 16px rgba(0, 0, 0, 0.16);
}

#ui-container {
    left: 50%;
    bottom: calc(var(--viewport-bottom-inset, 0px) + env(safe-area-inset-bottom) + 14px);
    width: min(92vw, 420px);
    padding: 0;
    gap: 10px;
    align-items: stretch;
    justify-content: flex-end;
    transform: translateX(-50%);
}

#player-status,
#player-controls {
    width: 100%;
    max-width: none;
    border-radius: 16px;
    padding: 12px;
    background: linear-gradient(180deg, rgba(5, 12, 23, 0.86), rgba(17, 24, 36, 0.94));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.26);
    pointer-events: auto;
}

#player-status {
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: stretch;
    color: white;
    font-size: 0.82rem;
}

.status-card {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 7px 8px;
    border-radius: 11px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.status-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.status-card-label {
    display: none;
}

.status-card-value {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff7e4;
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1;
}

.status-card-hp,
.status-card-power {
    display: grid;
    align-items: center;
    gap: 7px;
}

.status-card-hp {
    grid-template-columns: minmax(0, 1fr) auto;
}

.status-card-power {
    grid-template-columns: minmax(0, 1fr) auto auto;
}

.status-card-hp .status-card-head,
.status-card-power .status-card-head {
    justify-content: flex-end;
}

.status-card-hp .status-card-head {
    order: 2;
}

.status-card-hp #hp-bar {
    order: 1;
}

.status-card-power .status-card-head {
    order: 2;
}

.status-card-power .power-meter {
    order: 1;
    min-width: 0;
}

.status-card-power .power-meta {
    order: 3;
}

.status-card-power .status-card-head,
.status-card-power .power-meta {
    display: none;
}

#hp-bar {
    width: 100%;
    max-width: none;
    position: relative;
    height: 11px;
    background-color: #203040;
    border-radius: 999px;
    overflow: hidden;
}

.hp-label {
    display: none;
}

.hp-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #42d576, #b7ef61);
    transition: width 0.3s;
}

.power-meta {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 5px;
    font-size: 0.66rem;
    color: rgba(255, 255, 255, 0.72);
}

.power-last strong,
.status-round strong {
    color: #fff2c8;
    font-size: 0.82rem;
}

.compact-round {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    line-height: 1;
}

.status-card-weapon {
    gap: 4px;
    min-width: 0;
    padding-top: 5px;
    padding-bottom: 5px;
}

.weapon-status-value {
    justify-content: flex-start;
    min-width: 0;
    font-size: 0.78rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.weapon-status-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
    scrollbar-width: none;
}

.status-card-weapon .status-card-head,
.status-card-weapon .weapon-status-meta {
    display: none;
}

.weapon-status-meta::-webkit-scrollbar,
.weapon-selector::-webkit-scrollbar {
    display: none;
}

.weapon-meta-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    padding: 3px 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(235, 241, 248, 0.82);
    font-size: 0.66rem;
}

.weapon-meta-chip strong {
    color: #fff3cf;
    font-size: 0.76rem;
}

.weapon-meta-event {
    color: rgba(184, 217, 255, 0.84);
}

.weapon-selector {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    overflow: visible;
    padding-bottom: 0;
    pointer-events: auto;
}

@media (min-width: 900px) {
    .weapon-selector {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

.weapon-select-btn {
    min-width: 0;
    width: 100%;
    padding: 5px 6px;
    border-radius: 9px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: #f6f8fc;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease, opacity 0.16s ease;
}

.weapon-select-icon {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: rgba(236, 243, 252, 0.95);
}

.weapon-select-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.weapon-select-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    border-color: rgba(130, 203, 255, 0.38);
}

.weapon-select-btn.is-active {
    border-color: rgba(255, 213, 122, 0.45);
    background: linear-gradient(180deg, rgba(255, 197, 111, 0.18), rgba(255, 255, 255, 0.06));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.weapon-select-btn.is-empty {
    opacity: 0.42;
    filter: grayscale(1) brightness(0.72);
    position: relative;
}

.weapon-select-btn.is-empty::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 72%;
    height: 72%;
    max-width: 34px;
    max-height: 34px;
    min-width: 20px;
    min-height: 20px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 2.5px solid rgba(255, 70, 70, 0.92);
    background: linear-gradient(
        135deg,
        transparent calc(50% - 1.75px),
        rgba(255, 70, 70, 0.92) calc(50% - 1.75px),
        rgba(255, 70, 70, 0.92) calc(50% + 1.75px),
        transparent calc(50% + 1.75px)
    );
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.45),
        0 0 6px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

.weapon-select-btn:disabled {
    cursor: not-allowed;
}

.weapon-select-name {
    font-size: 0.58rem;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.weapon-select-ammo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    padding: 1px 5px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.22);
    color: #ffefbd;
    font-size: 0.58rem;
    font-weight: 800;
}

#game-container.status-jammed #power-meter-fill,
#game-container.status-jammed #power-meter-ghost,
#game-container.status-jammed .power-meter-grid,
#game-container.status-jammed .angle-dial-face,
#game-container.status-jammed .angle-dial-ticks,
#game-container.status-jammed .angle-needle,
#game-container.status-jammed .angle-dial-base,
#game-container.status-jammed .angle-origin,
#game-container.status-jammed #power-value,
#game-container.status-jammed .angle-stepper-value {
    opacity: 0 !important;
}

#game-container.status-jammed .power-meter,
#game-container.status-jammed .angle-dial {
    background:
        linear-gradient(135deg, rgba(42, 96, 125, 0.24), rgba(6, 18, 28, 0.52)),
        repeating-linear-gradient(90deg, rgba(150, 232, 255, 0.15) 0 5px, rgba(0, 0, 0, 0.05) 5px 10px);
    box-shadow: inset 0 0 0 1px rgba(118, 218, 255, 0.18), 0 0 18px rgba(58, 175, 224, 0.14);
}

#game-container.status-jammed .power-meter::after,
#game-container.status-jammed .angle-dial::after {
    content: 'JAMMED';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.62rem;
    font-weight: 900;
    letter-spacing: 0.16em;
    color: rgba(224, 248, 255, 0.88);
    text-shadow: 0 0 12px rgba(98, 214, 255, 0.35);
    pointer-events: none;
}

.status-aux {
    display: none;
}

#cooldowns {
    display: flex;
    gap: 10px;
}

#cooldowns div {
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 12px;
}

#move-cooldown, #fire-cooldown {
    background-color: #4CAF50;
}

#move-cooldown.cooling, #fire-cooldown.cooling {
    background-color: #f44336;
}

#turn-status,
#players-remaining {
    font-weight: bold;
    font-size: 12px;
}

#turn-status {
    color: #f8d79a;
}

#player-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: white;
    margin-bottom: 0;
    touch-action: manipulation;
}

.control-strip {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.2fr) 92px;
    gap: 8px;
    align-items: start;
}

.control-panel {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 8px;
    min-height: 116px;
    padding: 10px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.control-panel-label {
    font-size: 0.64rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: rgba(205, 229, 255, 0.72);
}

.angle-stepper .angle-dial {
    max-width: 128px;
    height: 76px;
    margin: 0 auto 4px;
    cursor: pointer;
}

.angle-stepper .angle-dial-face {
    left: 7px;
    right: 7px;
    top: 4px;
    bottom: 12px;
    border-width: 2px;
}

.angle-stepper .angle-tick {
    bottom: 12px;
}

.angle-stepper .angle-tick::before {
    left: 40px;
    width: 4px;
}

.angle-stepper .angle-tick.medium::before {
    width: 6px;
}

.angle-stepper .angle-tick.major::before {
    width: 8px;
}

.angle-stepper .angle-tick span {
    display: none;
}

.angle-stepper .angle-dial-base {
    left: 10px;
    right: 10px;
    bottom: 12px;
    height: 3px;
}

.angle-stepper .angle-needle {
    width: 52px;
    bottom: 12px;
    height: 3px;
}

.angle-stepper .angle-needle::after {
    right: -6px;
    width: 10px;
    height: 10px;
    border-width: 1px;
    box-shadow: 0 0 0 1px rgba(211, 154, 63, 0.9);
}

.angle-stepper .angle-origin {
    bottom: 6px;
    width: 11px;
    height: 11px;
    border-width: 2px;
}

.angle-stepper-body {
    display: flex;
    justify-content: center;
    align-items: center;
}

.angle-step-btn {
    width: 34px;
    height: 34px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    background: linear-gradient(180deg, #45556a, #2a3544);
    color: white;
    font-size: 1.08rem;
    font-weight: 800;
    cursor: pointer;
}

.angle-step-btn:disabled {
    opacity: 0.42;
    cursor: not-allowed;
}

.angle-stepper-value,
#angle-value {
    display: none !important;
}

.move-pad-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    flex: 0 0 auto;
}

.move-pad.control-panel {
    min-height: 88px;
    justify-content: flex-start;
    gap: 6px;
}

.move-budget {
    position: relative;
    width: 100%;
    height: 4px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.12);
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.18);
}

.move-budget-fill {
    width: 100%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, rgba(110, 209, 192, 0.96), rgba(215, 255, 248, 0.96));
    box-shadow: 0 0 10px rgba(110, 209, 192, 0.26);
    transition: width 0.12s linear, opacity 0.16s ease;
}

.move-pad .move-action-btn {
    min-height: 46px;
    padding: 0 12px;
}

.move-pad .move-action-label {
    display: none;
}

#fire-btn {
    width: 100%;
    min-width: 0;
    min-height: 88px;
    height: 88px;
    justify-self: stretch;
    align-self: start;
}

#toggle-ai-btn {
    display: none;
    width: 100%;
    min-height: 40px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    color: white;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

@keyframes turnPulseLocal {
    0%, 100% {
        box-shadow: 0 0 18px rgba(255, 84, 84, 0.32), inset 0 0 12px rgba(255, 84, 84, 0.1);
    }

    50% {
        box-shadow: 0 0 42px rgba(255, 70, 70, 0.84), inset 0 0 26px rgba(255, 70, 70, 0.22);
    }
}

@keyframes turnPulseWaiting {
    0%, 100% {
        box-shadow: 0 0 14px rgba(61, 141, 255, 0.26), inset 0 0 12px rgba(61, 141, 255, 0.08);
    }

    50% {
        box-shadow: 0 0 26px rgba(61, 141, 255, 0.46), inset 0 0 18px rgba(61, 141, 255, 0.14);
    }
}

@keyframes turnPulsePaused {
    0%, 100% {
        box-shadow: 0 0 16px rgba(255, 179, 69, 0.24), inset 0 0 12px rgba(255, 179, 69, 0.08);
    }

    50% {
        box-shadow: 0 0 30px rgba(255, 179, 69, 0.56), inset 0 0 22px rgba(255, 179, 69, 0.18);
    }
}

@keyframes turnPulseResolving {
    0%, 100% {
        box-shadow: 0 0 14px rgba(255, 111, 0, 0.24), inset 0 0 12px rgba(255, 111, 0, 0.08);
    }

    50% {
        box-shadow: 0 0 28px rgba(255, 111, 0, 0.5), inset 0 0 20px rgba(255, 111, 0, 0.16);
    }
}

@keyframes canvasTurnPulse {
    0%, 100% {
        box-shadow:
            0 0 0 5px rgba(255, 88, 88, 0.84),
            0 0 18px rgba(255, 78, 78, 0.3);
    }

    50% {
        box-shadow:
            0 0 0 8px rgba(255, 76, 76, 1),
            0 0 42px rgba(255, 68, 68, 0.62);
    }
}

@keyframes hudTurnFlash {
    0%, 100% {
        box-shadow: 0 14px 26px rgba(104, 20, 20, 0.28);
        filter: brightness(1);
    }

    50% {
        box-shadow: 0 18px 38px rgba(176, 32, 32, 0.46);
        filter: brightness(1.16);
    }
}

/* Login & Room Screen */
#login-screen, #room-screen, #game-over-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background:
        radial-gradient(circle at 16% 18%, rgba(71, 124, 255, 0.18), transparent 28%),
        radial-gradient(circle at 84% 12%, rgba(255, 151, 76, 0.14), transparent 24%),
        linear-gradient(180deg, rgba(9, 15, 24, 0.98), rgba(3, 5, 8, 1));
    color: white;
    z-index: 20;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: max(24px, env(safe-area-inset-top)) 16px max(40px, env(safe-area-inset-bottom));
}

#login-screen::before,
#room-screen::before,
#game-over-screen::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
    background-size: 120px 120px;
    opacity: 0.24;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.95), rgba(0, 0, 0, 0.35) 72%, transparent);
    pointer-events: none;
}

#login-screen::after,
#room-screen::after,
#game-over-screen::after {
    content: "";
    position: absolute;
    left: -8%;
    right: -8%;
    bottom: -6%;
    height: 34%;
    background:
        radial-gradient(circle at 24% 18%, rgba(255, 182, 96, 0.24), transparent 18%),
        radial-gradient(circle at 72% 24%, rgba(105, 231, 157, 0.16), transparent 20%),
        linear-gradient(180deg, rgba(30, 46, 33, 0.96), rgba(10, 14, 11, 0.98));
    clip-path: polygon(0 80%, 8% 74%, 15% 78%, 22% 68%, 31% 74%, 39% 60%, 48% 72%, 55% 64%, 66% 76%, 75% 69%, 84% 79%, 92% 71%, 100% 76%, 100% 100%, 0 100%);
    opacity: 0.95;
    pointer-events: none;
}

.screen-shell {
    position: relative;
    z-index: 1;
    width: min(1120px, 100%);
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
    gap: 22px;
    align-items: stretch;
}

.screen-shell-login {
    grid-template-areas:
        "hero command"
        "rooms rooms";
}

.screen-shell-room {
    grid-template-areas:
        "hero intel"
        "roster roster";
}

.screen-shell-gameover {
    width: min(520px, 100%);
    display: block;
}

.screen-hero,
.screen-panel {
    position: relative;
    overflow: hidden;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background:
        linear-gradient(180deg, rgba(14, 22, 34, 0.9), rgba(8, 11, 16, 0.88));
    box-shadow:
        0 24px 54px rgba(0, 0, 0, 0.34),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.screen-hero::before,
.screen-panel::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.06), transparent 30%),
        linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.18));
    pointer-events: none;
}

.screen-hero > *,
.screen-panel > * {
    position: relative;
    z-index: 2;
}

.screen-hero {
    grid-area: hero;
    min-height: 320px;
    padding: 28px 30px 110px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 16px;
}

.screen-hero::after {
    content: "";
    position: absolute;
    right: 18px;
    bottom: 22px;
    width: min(280px, 42vw);
    height: 132px;
    background:
        radial-gradient(circle at 24% 24%, rgba(255, 176, 91, 0.48), transparent 14%),
        linear-gradient(180deg, rgba(96, 118, 86, 0.92), rgba(24, 31, 22, 0.96));
    clip-path: polygon(4% 84%, 14% 70%, 31% 70%, 40% 58%, 49% 58%, 55% 45%, 76% 45%, 82% 52%, 96% 52%, 100% 66%, 100% 100%, 0 100%);
    opacity: 0.76;
    filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.34));
    pointer-events: none;
}

.screen-tank-art {
    position: absolute;
    pointer-events: none;
    user-select: none;
    z-index: 1;
}

.screen-tank-art svg {
    display: block;
    width: 100%;
    height: auto;
    filter: drop-shadow(0 16px 26px rgba(0, 0, 0, 0.34));
}

.screen-tank-art-hero {
    right: 16px;
    bottom: 12px;
    width: min(320px, 50vw);
    opacity: 0.98;
}

.screen-tank-art-browser {
    width: min(220px, 32vw);
    flex: 0 0 auto;
    opacity: 0.95;
}

.screen-kicker,
.screen-panel-kicker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    font-size: 0.76rem;
    font-weight: bold;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: rgba(173, 213, 255, 0.78);
}

.screen-kicker::before,
.screen-panel-kicker::before {
    content: "";
    width: 24px;
    height: 1px;
    background: currentColor;
    opacity: 0.7;
}

#login-screen h1,
#room-screen h2,
#game-over-screen h2,
.screen-panel h3 {
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    letter-spacing: 0.02em;
}

#login-screen h1 {
    font-size: clamp(2.2rem, 4vw, 3.8rem);
    line-height: 0.98;
    max-width: 8ch;
}

#room-screen h2,
#game-over-screen h2 {
    font-size: clamp(1.9rem, 3vw, 3rem);
    line-height: 1.02;
}

.screen-panel h3 {
    font-size: 1.25rem;
    margin-top: 6px;
}

.screen-subtitle {
    max-width: 34rem;
    color: rgba(232, 239, 246, 0.76);
    line-height: 1.6;
    font-size: 1rem;
}

.screen-badge-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: auto;
}

.screen-badge {
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.86);
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.screen-panel {
    padding: 22px;
}

.screen-panel-head {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 18px;
}

.screen-panel-head-split {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.commander-panel {
    grid-area: command;
}

.room-browser-panel {
    grid-area: rooms;
    border-color: rgba(120, 186, 255, 0.36);
    background:
        linear-gradient(180deg, rgba(10, 24, 42, 0.98), rgba(4, 11, 22, 0.96));
    box-shadow:
        0 28px 58px rgba(0, 0, 0, 0.38),
        inset 0 0 0 1px rgba(110, 184, 255, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.room-browser-panel::after {
    content: "";
    position: absolute;
    inset: 14px;
    border-radius: 18px;
    border: 1px solid rgba(110, 184, 255, 0.14);
    pointer-events: none;
}

.room-browser-panel .screen-panel-head {
    position: relative;
    padding-bottom: 14px;
    margin-bottom: 16px;
    border-bottom: 1px solid rgba(110, 184, 255, 0.24);
}

.room-browser-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 16px;
    padding: 16px 18px;
    border-radius: 18px;
    background:
        radial-gradient(circle at top left, rgba(120, 196, 255, 0.16), transparent 38%),
        linear-gradient(180deg, rgba(15, 37, 64, 0.96), rgba(9, 21, 38, 0.92));
    border: 1px solid rgba(124, 194, 255, 0.2);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.room-browser-banner-copy {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.room-browser-banner-label {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.22em;
    color: rgba(149, 214, 255, 0.78);
}

.room-browser-banner-copy strong {
    font-size: 1.1rem;
    color: #f4f8ff;
    line-height: 1.2;
}

.room-intel-panel {
    grid-area: intel;
}

.room-roster-panel {
    grid-area: roster;
}

.game-over-panel {
    text-align: center;
    padding: 36px 30px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
}

.login-form input,
.login-form select,
#create-room-btn,
#join-room-btn,
#refresh-rooms-btn,
#start-game-btn,
#play-again-btn,
#solo-game-btn,
#leave-room-btn {
    min-height: 52px;
    padding: 12px 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    font-size: 1rem;
}

.login-form input {
    background: rgba(7, 11, 16, 0.88);
    color: #f5f9fd;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.login-form select {
    width: 100%;
    appearance: none;
    background:
        linear-gradient(180deg, rgba(12, 18, 25, 0.96), rgba(8, 13, 18, 0.96));
    color: #f5f9fd;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.login-form input::placeholder {
    color: rgba(214, 225, 237, 0.42);
}

.solo-options-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 14px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(9, 14, 20, 0.7);
}

.solo-options-label {
    flex: 0 0 auto;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(195, 215, 236, 0.8);
}

#solo-player-count {
    flex: 1 1 auto;
    min-width: 0;
    padding-right: 42px;
    background-image:
        linear-gradient(45deg, transparent 50%, rgba(232, 240, 249, 0.82) 50%),
        linear-gradient(135deg, rgba(232, 240, 249, 0.82) 50%, transparent 50%);
    background-position:
        calc(100% - 18px) calc(50% - 3px),
        calc(100% - 12px) calc(50% - 3px);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
}

#create-room-btn,
#join-room-btn,
#start-game-btn,
#play-again-btn,
#solo-game-btn,
#leave-room-btn,
#refresh-rooms-btn,
#add-ai-btn,
.lobby-join-btn {
    background: linear-gradient(180deg, #5fcc85, #2b9a55);
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.16s ease, filter 0.16s ease, background 0.16s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

#create-room-btn {
    background: linear-gradient(180deg, #ffbf66, #d57b23);
    color: #1b1207;
    border-color: rgba(255, 205, 133, 0.48);
    box-shadow:
        0 12px 24px rgba(213, 123, 35, 0.28),
        inset 0 1px 0 rgba(255, 243, 217, 0.3);
}

#start-game-btn,
#play-again-btn,
#add-ai-btn {
    background: linear-gradient(180deg, #5fcc85, #2b9a55);
}

#refresh-rooms-btn,
#leave-room-btn,
.secondary-btn {
    background: linear-gradient(180deg, #4e6079, #364459);
}

#solo-game-btn,
#refresh-rooms-btn {
    background: linear-gradient(180deg, #4d7dff, #2952c9);
}

.lobby-join-btn {
    background: linear-gradient(180deg, #6fe3a0, #239458);
    border-color: rgba(147, 244, 186, 0.48);
    box-shadow:
        0 12px 24px rgba(35, 148, 88, 0.28),
        inset 0 1px 0 rgba(226, 255, 239, 0.24);
}

#create-room-btn,
.lobby-join-btn {
    position: relative;
    overflow: hidden;
}

#create-room-btn::before,
.lobby-join-btn::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.22), transparent 36%);
    pointer-events: none;
}

.button-lead {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(22, 14, 5, 0.18);
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.16em;
}

#create-room-btn:hover,
#join-room-btn:hover,
#start-game-btn:hover,
#play-again-btn:hover,
#solo-game-btn:hover,
#refresh-rooms-btn:hover,
#leave-room-btn:hover,
#add-ai-btn:hover,
.lobby-join-btn:hover {
    filter: brightness(1.06);
    transform: translateY(-1px);
}

#refresh-rooms-btn:hover,
#leave-room-btn:hover,
.secondary-btn:hover {
    filter: brightness(1.08);
}

#start-game-btn:disabled {
    background: linear-gradient(180deg, #6a717d, #4a5059);
    cursor: not-allowed;
    filter: none;
    transform: none;
}

#player-list {
    background: rgba(255, 255, 255, 0.045);
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 12px;
    width: 100%;
    margin: 0 0 16px;
    max-height: 300px;
    overflow-y: auto;
}

.player-list-header {
    font-weight: bold;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 0.92rem;
    color: rgba(243, 248, 255, 0.88);
}

.player-list-item {
    padding: 10px 0;
    display: flex;
    align-items: center;
    font-size: 0.94rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.player-color {
    width: 14px;
    height: 14px;
    border-radius: 999px;
    margin-right: 10px;
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.18);
}

/* Game Over Screen */
#winner-display {
    font-size: 1.2rem;
    margin: 18px 0 24px;
    color: rgba(255, 255, 255, 0.84);
}

.hidden {
    display: none !important;
}

.lobby-button-row,
.room-action-row {
    display: flex;
    gap: 12px;
    width: 100%;
}

.lobby-button-row > *,
.room-action-row > * {
    flex: 1;
}

.lobby-notice {
    width: 100%;
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(255, 198, 40, 0.11);
    border: 1px solid rgba(255, 198, 40, 0.22);
    color: #ffe7a0;
    font-size: 0.92rem;
    text-align: left;
}

.lobby-room-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    min-height: 220px;
    padding: 14px;
    border-radius: 18px;
    background:
        linear-gradient(180deg, rgba(8, 18, 32, 0.9), rgba(4, 9, 18, 0.94));
    border: 1px solid rgba(110, 184, 255, 0.16);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.03),
        inset 0 0 0 1px rgba(93, 166, 255, 0.05);
}

.lobby-room-empty {
    padding: 18px 20px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px dashed rgba(255, 255, 255, 0.16);
    color: rgba(255, 255, 255, 0.74);
    text-align: center;
    line-height: 1.55;
}

.lobby-room-card {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    align-items: stretch;
    padding: 14px;
    border-radius: 18px;
    background:
        linear-gradient(180deg, rgba(17, 31, 48, 0.94), rgba(9, 16, 28, 0.96));
    border: 1px solid rgba(116, 188, 255, 0.24);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.04),
        0 14px 26px rgba(0, 0, 0, 0.22);
}

.lobby-room-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    border-radius: 18px 0 0 18px;
    background: linear-gradient(180deg, rgba(102, 184, 255, 0.88), rgba(74, 133, 255, 0.38));
    pointer-events: none;
}

.lobby-room-card.is-disabled {
    opacity: 0.72;
}

.lobby-room-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.lobby-room-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: flex-start;
}

.lobby-room-title-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.lobby-room-title {
    font-size: 1.08rem;
    font-weight: bold;
    letter-spacing: 0.08em;
}

.lobby-room-code {
    display: inline-flex;
    align-self: flex-start;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.07);
    color: rgba(201, 222, 255, 0.88);
    font-size: 0.74rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.lobby-room-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 72px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(95, 230, 133, 0.12);
    color: #9ef0b6;
    font-size: 0.82rem;
    font-weight: bold;
}

.lobby-room-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.lobby-room-meta-chip {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(232, 239, 246, 0.76);
    font-size: 0.8rem;
    letter-spacing: 0.04em;
}

.lobby-room-action {
    display: flex;
    align-items: center;
}

.lobby-join-btn {
    min-width: 116px;
    min-height: 58px;
    padding: 14px 18px;
    font-size: 0.96rem;
    border-radius: 16px;
}

.lobby-join-btn:disabled {
    background: linear-gradient(180deg, #666d79, #444a53);
    cursor: not-allowed;
    filter: none;
    transform: none;
}

.room-meta-panel {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    width: 100%;
}

.room-meta-card {
    padding: 14px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center;
}

.room-meta-label {
    display: block;
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 6px;
}

.room-status-message {
    width: 100%;
    margin-top: 10px;
    padding: 14px 16px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.82);
    text-align: left;
    font-size: 0.96rem;
    line-height: 1.5;
}

/* Responsive adjustments */
@media (max-width: 768px), (hover: none) and (pointer: coarse) {
    .screen-shell,
    .screen-shell-login,
    .screen-shell-room {
        grid-template-columns: 1fr;
        grid-template-areas:
            "hero"
            "command"
            "rooms";
        gap: 16px;
    }

    .screen-shell-room {
        grid-template-areas:
            "hero"
            "intel"
            "roster";
    }

    .screen-hero,
    .screen-panel {
        border-radius: 20px;
    }

    .screen-hero {
        min-height: 0;
        padding: 22px 18px 104px;
    }

    .screen-tank-art-hero {
        width: min(250px, 52vw);
        right: 14px;
        bottom: 12px;
    }

    .screen-hero::after {
        width: min(220px, 56vw);
        height: 112px;
        right: 12px;
        bottom: 16px;
    }

    .screen-panel {
        padding: 16px;
    }

    .room-browser-banner {
        padding: 14px 14px;
        gap: 12px;
    }

    .room-browser-banner-copy strong {
        font-size: 0.98rem;
    }

    .screen-tank-art-browser {
        width: 146px;
    }

    .screen-panel-head-split {
        flex-direction: column;
        align-items: stretch;
    }

    #refresh-rooms-btn {
        width: 100%;
    }

    #ui-container {
        width: min(94vw, 390px);
        bottom: calc(var(--viewport-bottom-inset, 0px) + env(safe-area-inset-bottom) + 24px);
        gap: 8px;
    }

    #player-controls,
    #player-status {
        padding: 9px;
        border-radius: 14px;
        gap: 4px;
    }

    .status-card {
        padding: 6px 7px;
        gap: 5px;
    }

    .status-card-label,
    .control-panel-label {
        font-size: 0.58rem;
        letter-spacing: 0.14em;
    }

    .status-card-value {
        min-width: 0;
        padding: 2px 6px;
        font-size: 0.76rem;
    }

    #hp-bar,
    .power-meter {
        height: 9px;
    }

    .power-meta {
        gap: 4px;
        font-size: 0.6rem;
    }

    .power-last strong,
    .status-round strong {
        font-size: 0.8rem;
    }

    .control-strip {
        grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr) 74px;
        gap: 6px;
    }

    .control-panel {
        min-height: 76px;
        padding: 8px;
        gap: 6px;
    }

    .move-pad.control-panel {
        min-height: 70px;
    }

    .move-budget {
        height: 3px;
    }

    .angle-stepper-body {
        justify-content: center;
    }

    .angle-stepper .angle-dial {
        max-width: 116px;
        height: 68px;
    }

    .move-pad-buttons {
        gap: 6px;
    }

    .move-pad .move-action-btn {
        min-height: 42px;
        padding: 0 8px;
    }

    .move-action-icon {
        font-size: 1rem;
    }

    .move-action-label {
        display: none;
    }

    #fire-btn {
        min-height: 70px;
        height: 70px;
        gap: 3px;
    }

    #fire-btn .fire-action-core {
        width: 13px;
        height: 13px;
    }

    #fire-btn .fire-action-label {
        font-size: 0.58rem;
    }

    .lobby-button-row,
    .room-action-row {
        flex-direction: column;
    }

    .solo-options-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .lobby-room-card {
        grid-template-columns: 1fr;
    }

    .lobby-room-head {
        flex-direction: column;
        align-items: stretch;
    }

    .lobby-room-count {
        align-self: flex-start;
    }

    .lobby-room-action {
        width: 100%;
    }

    .lobby-join-btn {
        width: 100%;
        min-height: 56px;
    }

    .turn-banner {
        top: calc(env(safe-area-inset-top) + 8px);
        min-width: min(92vw, 300px);
        max-width: min(94vw, 380px);
        gap: 8px;
        padding: 8px 10px;
        border-radius: 12px;
    }

    .combat-event {
        top: calc(env(safe-area-inset-top) + 64px);
        min-width: min(84vw, 240px);
        max-width: min(90vw, 320px);
        padding: 7px 10px;
        font-size: 0.74rem;
    }

    .turn-banner-label {
        padding: 3px 7px;
        font-size: 0.62rem;
    }

    .turn-banner-message {
        font-size: 0.88rem;
    }

    .turn-banner-copy {
        font-size: 0.82rem;
    }

    .turn-banner-count {
        font-size: 1.04rem;
    }

    .turn-banner-sub {
        font-size: 0.72rem;
    }

    .player-list-item {
        font-size: 0.8rem;
    }

    .weapon-status-value {
        font-size: 0.72rem;
    }

    .weapon-select-btn {
        min-width: 0;
        padding: 4px 5px;
        border-radius: 8px;
    }

    .weapon-select-name {
        font-size: 0.54rem;
    }

    .weapon-select-ammo {
        font-size: 0.56rem;
    }

    .power-meta {
        font-size: 0.64rem;
    }

    .room-meta-panel {
        grid-template-columns: 1fr;
    }

    #login-screen h1 {
        font-size: 1.9rem;
    }

    #room-screen h2,
    #game-over-screen h2 {
        font-size: 1.6rem;
    }
}

@media (hover: none) and (pointer: coarse) and (orientation: landscape) and (max-height: 560px) {
    #ui-container {
        width: min(94vw, 520px);
        bottom: calc(var(--viewport-bottom-inset, 0px) + env(safe-area-inset-bottom) + 12px);
        gap: 6px;
    }

    #player-controls,
    #player-status {
        padding: 8px 10px;
    }

    .control-strip {
        grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.05fr) 70px;
        gap: 6px;
    }

    .control-panel {
        min-height: 68px;
        padding: 7px 8px;
    }

    .move-pad.control-panel {
        min-height: 62px;
    }

    .move-budget {
        height: 3px;
    }

    #fire-btn {
        min-height: 62px;
        height: 62px;
    }
}

@media (min-width: 768px) and (hover: hover) and (pointer: fine) {
    .control-row {
        flex-direction: row;
    }
    
    .control-group {
        flex: 1;
    }
}

@media (max-height: 600px) and (hover: hover) and (pointer: fine) {
    #ui-container {
        bottom: 10px;
    }
}

/* Landscape mode for mobile */
@media (max-height: 450px) and (orientation: landscape) and (hover: hover) and (pointer: fine) {
    #ui-container {
        width: min(90vw, 760px);
        bottom: 8px;
        gap: 8px;
    }

    #player-controls,
    #player-status {
        padding: 10px;
    }

    .control-strip {
        grid-template-columns: 120px minmax(0, 1fr) 88px;
    }
}

/* Add AI Player Button */
#add-ai-btn {
    padding: 8px 16px;
    background-color: #5b5bb7;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
}

#add-ai-btn:hover {
    background-color: #4a4aa6;
}

/* Draggable gameplay panels — appended. Users can drag these out of the way so
   tanks/terrain are not obscured. Positions persist in localStorage; double-click
   a panel's background to reset. */
#ui-container {
    transform: translate(calc(-50% + var(--drag-x, 0px)), var(--drag-y, 0px));
}

.turn-banner {
    transform: translate(calc(-50% + var(--drag-x, 0px)), var(--drag-y, 0px));
    pointer-events: auto;
    cursor: grab;
    touch-action: none;
}

.combat-event {
    transform: translate(calc(-50% + var(--drag-x, 0px)), var(--drag-y, 0px));
    pointer-events: auto;
    cursor: grab;
    touch-action: none;
}

#player-status,
#player-controls {
    cursor: grab;
    touch-action: none;
}

.turn-banner.panel-dragging,
.combat-event.panel-dragging,
#player-status.panel-dragging,
#player-controls.panel-dragging {
    cursor: grabbing;
    user-select: none;
    opacity: 0.92;
}

/* Server ping indicator — small HUD badge in top-right */
.ping-indicator {
    position: absolute;
    top: calc(env(safe-area-inset-top) + 12px);
    right: calc(env(safe-area-inset-right) + 12px);
    padding: 4px 10px;
    border-radius: 999px;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    background: rgba(8, 14, 24, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 16;
    pointer-events: none;
    user-select: none;
    white-space: nowrap;
}

.ping-indicator.ping-good    { color: #8ee67a; border-color: rgba(142, 230, 122, 0.35); }
.ping-indicator.ping-ok      { color: #ffd86b; border-color: rgba(255, 216, 107, 0.35); }
.ping-indicator.ping-bad     { color: #ff8a8a; border-color: rgba(255, 138, 138, 0.35); }
.ping-indicator.ping-offline { color: #9aa3b2; border-color: rgba(154, 163, 178, 0.25); font-style: italic; }

/* Angle dial tilt — rotates to match the local tank's terrain angle so the
   dial visually aligns with the tilted tank body when sitting on slopes.
   Pivot at the needle base so the base stays anchored as the dial tilts. */
.angle-dial {
    transform: rotate(var(--dial-tilt, 0deg));
    transform-origin: 50% calc(100% - 18px);
}

.angle-stepper .angle-dial {
    transform-origin: 50% calc(100% - 12px);
}
