/* PolySnake viewer stylesheet: circa-2015 CSS 3, flat lean-paint, Tizen 2.4 / Mali-400 & smartphone safe. */
* {
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #235234;
    color: #f6f8fa;
    font-family: "Trebuchet MS", "Segoe UI", Arial, Helvetica, sans-serif;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

#world, #world canvas {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    display: block;
}

#world {
    cursor: grab;
    touch-action: none;
}

#world.is-dragging {
    cursor: grabbing;
}

/* Top-left HUD & Scoreboard stack */
#hud-left-stack {
    position: fixed;
    top: 10px;
    left: 10px;
    right: 96px;
    z-index: 6;
    pointer-events: none;
}

#hud-top {
    display: -webkit-flex;
    display: flex;
    -webkit-flex-wrap: wrap;
    flex-wrap: wrap;
    -webkit-align-items: center;
    align-items: center;
    pointer-events: none;
}

.hud-pill {
    display: inline-block;
    vertical-align: middle;
    margin: 0 6px 5px 0;
    padding: 5px 10px;
    border-radius: 8px;
    background: rgba(16, 28, 24, 0.86);
    border: 1px solid rgba(255, 255, 255, 0.28);
    font-size: 13px;
    line-height: 1.25;
    color: #f6f8fa;
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.hud-tag {
    display: inline-block;
    padding: 1px 6px;
    margin-right: 6px;
    border-radius: 4px;
    background: #22c55e;
    color: #0e1c14;
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 0.6px;
    vertical-align: middle;
}

.hud-title {
    font-weight: bold;
    letter-spacing: 0.2px;
    vertical-align: middle;
}

.hud-stats {
    font-family: monospace;
    font-size: 13px;
}

.stat-label {
    font-family: "Trebuchet MS", Arial, sans-serif;
    font-size: 10px;
    font-weight: bold;
    color: #a9d0bf;
    letter-spacing: 0.6px;
    margin-right: 3px;
}

.hud-divider {
    display: inline-block;
    width: 1px;
    height: 12px;
    margin: 0 7px;
    background: rgba(255, 255, 255, 0.25);
    vertical-align: middle;
}

.hud-btn {
    pointer-events: auto;
    display: inline-block;
    vertical-align: middle;
    margin: 0 6px 5px 0;
    padding: 5px 11px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.34);
    background: rgba(20, 32, 36, 0.88);
    color: #ffffff;
    font-family: inherit;
    font-size: 12px;
    line-height: 1.25;
    font-weight: bold;
    cursor: pointer;
}

.hud-btn-primary {
    background: #1e88e5;
    border-color: #7cc4ff;
}

.hud-btn:hover, .hud-btn:active { background: #2e4254; }
.hud-btn-primary:hover, .hud-btn-primary:active { background: #1565c0; }

/* Top-right utility buttons */
#scene-controls {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 7;
    white-space: nowrap;
}

.scene-button {
    display: inline-block;
    vertical-align: top;
    width: 36px;
    height: 36px;
    padding: 7px;
    margin: 0 0 0 5px;
    border: 1px solid rgba(255, 255, 255, 0.40);
    border-radius: 8px;
    background: rgba(16, 28, 24, 0.86);
    color: #ffffff;
    cursor: pointer;
}

.scene-button svg {
    display: block;
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sound-off, .is-muted .sound-on { display: none; }
.is-muted .sound-off { display: block; }
.fullscreen-exit, .is-fullscreen .fullscreen-enter { display: none; }
.is-fullscreen .fullscreen-exit { display: block; }

/* Army Deployment Alert Banner */
.army-bar {
    position: fixed;
    top: 52px;
    left: 50%;
    -webkit-transform: translateX(-50%);
    transform: translateX(-50%);
    z-index: 7;
    width: 470px;
    max-width: 88%;
    padding: 7px 14px;
    border-radius: 10px;
    background: rgba(74, 16, 16, 0.94);
    border: 2px solid #ff5252;
    text-align: center;
    line-height: 1.26;
    word-wrap: break-word;
    pointer-events: none;
}

.army-bar.is-incoming {
    background: rgba(74, 48, 12, 0.94);
    border-color: #f5b027;
}

.army-bar.is-retreating {
    background: rgba(18, 54, 34, 0.94);
    border-color: #4ade80;
}

.army-title {
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 1px;
    color: #ffd56b;
}

.army-bar.is-retreating .army-title {
    color: #8bf5a8;
}

.army-sub {
    margin-top: 2px;
    font-size: 11px;
    color: #f4dede;
}

.army-bar.is-retreating .army-sub {
    color: #dff7e6;
}

/* Army Defeat Score Card & High-Score Celebration Banner */
.defeat-card {
    position: fixed;
    top: 32%;
    left: 50%;
    -webkit-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
    z-index: 9;
    width: 440px;
    max-width: 88%;
    padding: 16px 22px;
    border-radius: 14px;
    background: rgba(16, 26, 30, 0.94);
    border: 3px solid #ff7a29;
    text-align: center;
    word-wrap: break-word;
    pointer-events: none;
}

.defeat-card.is-highscore {
    background: rgba(34, 24, 6, 0.96);
    border-color: #ffd54f;
}

.defeat-tag {
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 1.4px;
    color: #ffab66;
    margin-bottom: 4px;
}

.defeat-card.is-highscore .defeat-tag {
    font-size: 15px;
    color: #ffe066;
}

.defeat-name {
    font-size: 20px;
    font-weight: bold;
    color: #ffffff;
    margin-bottom: 6px;
}

.defeat-score {
    font-family: monospace;
    font-size: 34px;
    font-weight: bold;
    letter-spacing: 1px;
    color: #4ade80;
    margin-bottom: 6px;
}

.defeat-card.is-highscore .defeat-score {
    color: #ffd54f;
}

.defeat-sub {
    font-size: 13px;
    line-height: 1.35;
    color: #d4ece4;
}

.defeat-card.is-highscore .defeat-sub {
    color: #fff3c4;
}

.confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

/* Live Snake Scoreboard HUD (stacked cleanly on left edge so center stays open for Army Alert) */
.party-hud {
    margin-top: 4px;
    width: 172px;
    max-width: 100%;
    pointer-events: none;
}

.p-card {
    display: block;
    width: 168px;
    padding: 5px 8px;
    margin: 0 0 5px 0;
    border-radius: 8px;
    background: rgba(16, 26, 28, 0.86);
    border: 1px solid rgba(255, 255, 255, 0.24);
}

.p-card.is-targeted {
    border-color: #ff5252;
    background: rgba(66, 18, 18, 0.92);
}

.p-card.is-combo {
    border-color: #ffd54f;
}

.p-row {
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    margin-bottom: 3px;
}

.p-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    margin-right: 6px;
    border: 1px solid #ffffff;
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
}

.p-name {
    -webkit-flex: 1;
    flex: 1;
    font-size: 13px;
    font-weight: bold;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.p-score {
    font-family: monospace;
    font-size: 12px;
    font-weight: bold;
    color: #ffd56b;
    margin-left: 6px;
}

.p-tier {
    font-size: 10px;
    font-weight: bold;
    color: #b7ded0;
    margin-bottom: 3px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.p-card.is-targeted .p-tier {
    color: #ff9c9c;
}

.bar-line {
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
}

.bar-lbl {
    width: 30px;
    margin-right: 5px;
    font-family: monospace;
    font-size: 10px;
    font-weight: bold;
    color: #9be4b4;
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
}

.mini-bar {
    -webkit-flex: 1;
    flex: 1;
    height: 7px;
    border-radius: 3px;
    background: #0e1718;
    overflow: hidden;
}

.mini-fill { height: 100%; width: 20%; }
.size-fill { background: #4ade80; }
.p-card.is-targeted .size-fill { background: #ff5252; }

/* Center Announcement Banner */
.center-banner {
    position: fixed;
    top: 24%;
    left: 50%;
    -webkit-transform: translateX(-50%);
    transform: translateX(-50%);
    z-index: 9;
    width: 580px;
    max-width: 90%;
    padding: 11px 22px;
    border-radius: 13px;
    background: rgba(16, 26, 28, 0.94);
    border: 3px solid #ffd56b;
    color: #ffffff;
    font-size: 26px;
    font-weight: bold;
    line-height: 1.24;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    text-align: center;
    white-space: normal;
    word-wrap: break-word;
    pointer-events: none;
}

.center-banner.is-alert {
    background: #641616;
    border-color: #ff6b6b;
}

.center-banner.is-info {
    font-size: 22px;
    padding: 9px 20px;
    border-color: #4ade80;
}

.center-banner.is-combo {
    font-size: 22px;
    padding: 9px 20px;
    background: rgba(54, 34, 6, 0.95);
    border-color: #ffd54f;
    color: #ffe885;
}

/* Lobby Overlay Card */
.overlay-card {
    position: fixed;
    top: 50%;
    left: 50%;
    -webkit-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
    z-index: 8;
    width: 540px;
    max-width: 92%;
    max-height: 84%;
    overflow-y: auto;
    padding: 18px 20px;
    border-radius: 16px;
    background: rgba(16, 26, 26, 0.95);
    border: 2px solid rgba(255, 255, 255, 0.28);
    color: #f6f8fa;
}

.overlay-header {
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    margin-bottom: 12px;
}

.overlay-icon {
    display: block;
    width: 62px;
    height: 62px;
    padding: 2px;
    border-radius: 12px;
    margin-right: 14px;
    background: #ffffff;
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
}

.overlay-eyebrow {
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 1.4px;
    color: #ffd56b;
    text-transform: uppercase;
}

.overlay-title {
    margin: 2px 0 0 0;
    font-size: 32px;
    line-height: 1.05;
}

.tier-banner {
    padding: 9px 12px;
    margin-bottom: 12px;
    border-radius: 10px;
    background: #1b3b28;
    border: 1px solid #45b86d;
}

.tier-banner-tag {
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 0.8px;
    color: #8bf5a8;
}

.tier-banner-sub {
    margin-top: 3px;
    font-size: 12px;
    line-height: 1.35;
    color: #e4f4ea;
}

.roster-grid {
    margin: 0 -4px 12px -4px;
    font-size: 0;
}

.roster-slot {
    display: inline-block;
    vertical-align: top;
    width: 50%;
    padding: 4px;
    font-size: 13px;
}

.roster-card {
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    padding: 7px 10px;
    border-radius: 8px;
    background: #1f2d33;
    border: 1px solid rgba(255, 255, 255, 0.14);
}

.roster-card.is-human {
    background: #1a3f2c;
    border-color: #5ee28a;
}

.roster-swatch {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    margin-right: 8px;
    border: 1px solid rgba(255, 255, 255, 0.78);
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
}

.roster-name {
    -webkit-flex: 1;
    flex: 1;
    font-weight: bold;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.roster-role {
    font-size: 10px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.12);
    color: #d0dde8;
}

.roster-card.is-human .roster-role {
    background: #249c52;
    color: #ffffff;
}

.overlay-actions {
    display: -webkit-flex;
    display: flex;
    -webkit-flex-wrap: wrap;
    flex-wrap: wrap;
    margin: 0 -5px;
}

.btn-big {
    -webkit-flex: 1;
    flex: 1;
    min-width: 136px;
    margin: 5px;
    padding: 13px 16px;
    border-radius: 10px;
    border: 2px solid transparent;
    font-family: inherit;
    font-size: 16px;
    font-weight: bold;
    color: #ffffff;
    cursor: pointer;
}

.btn-start { background: #26a050; border-color: #82f0a2; }
.btn-start:hover, .btn-start:active { background: #1e803f; }
.btn-local { background: #1e7fd6; border-color: #7cc4ff; }
.btn-local:hover, .btn-local:active { background: #1665ad; }

.overlay-hint {
    margin: 10px 0 0 0;
    font-size: 13px;
    line-height: 1.35;
    color: #c2dad0;
    text-align: center;
}

/* Floating Touch-Anywhere Steering Reticle */
.touch-guide {
    position: fixed;
    left: 0;
    top: 0;
    width: 112px;
    height: 112px;
    margin-left: -56px;
    margin-top: -56px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.55);
    background: rgba(16, 28, 28, 0.28);
    z-index: 6;
    pointer-events: none;
}

.touch-knob {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 42px;
    height: 42px;
    margin-left: -21px;
    margin-top: -21px;
    border-radius: 50%;
    border: 2px solid #ffffff;
    background: #22c55e;
    pointer-events: none;
}

/* Local Screen Play Status Chip (bottom-left) */
.local-controls {
    position: fixed;
    left: 12px;
    bottom: 12px;
    z-index: 7;
    pointer-events: none;
}

.local-hud-chip {
    pointer-events: auto;
    width: 248px;
    max-width: 80vw;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(16, 26, 28, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.28);
}

.local-chip-top {
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    -webkit-justify-content: space-between;
    justify-content: space-between;
    margin-bottom: 6px;
}

.local-snake-tag {
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 0.6px;
    color: #ffd56b;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.local-dash-btn {
    padding: 3px 10px;
    margin-left: 6px;
    border-radius: 6px;
    border: 1px solid #82f0a2;
    background: #24964c;
    color: #ffffff;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
}

.local-dash-btn:disabled {
    opacity: 0.45;
    cursor: default;
}

.local-exit-btn {
    padding: 3px 8px;
    margin-left: 5px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.30);
    background: #334154;
    color: #ffffff;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
}

.local-meta {
    margin-top: 5px;
    font-size: 11px;
    color: #cbe2d8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Canonical Standard RCWeb QR Panel (content-box restored, uniform scale only) */
#qrPanel {
    position: fixed;
    bottom: 14px;
    right: 14px;
    z-index: 6;
    width: 166px;
    -webkit-transform-origin: bottom right;
    transform-origin: bottom right;
    -webkit-transform: scale(0.62);
    transform: scale(0.62);
}

#qrPanel.is-compact {
    bottom: 14px;
    -webkit-transform: scale(0.44);
    transform: scale(0.44);
    opacity: 0.78;
}

.rcRoomQrCodeLink, .rcRoomQrCodeLink * {
    -webkit-box-sizing: content-box;
    box-sizing: content-box;
}

.rcRoomQrCodeLink {
    display: block;
    width: 150px;
    margin-left: auto;
    margin-right: auto;
    border: solid 8px #fff;
    border-radius: 8px;
    color: #fff;
    background-color: #fff;
    text-align: center;
    -webkit-transition: opacity 1s ease;
    transition: opacity 1s ease;
    text-decoration: none;
    -webkit-transform-origin: center;
    transform-origin: center;
    -webkit-transform: scale(1);
    transform: scale(1);
}

.rcTechLabel {
    background-color: #000;
    color: #fff;
    font-family: monospace;
    font-size: 13px;
    font-weight: bold;
    margin: 0 0 8px 0;
    padding: 4px;
    letter-spacing: 0.2em;
    border-radius: 8px 8px 0 0;
}

.rcRoomQrCode {
    width: 150px;
    height: 150px;
}

.rcRoomId {
    background-color: #000;
    color: #fff;
    font-family: monospace;
    font-size: 16px;
    padding: 4px;
    margin: 8px 0 0 0;
    letter-spacing: 0.25em;
    border-radius: 0 0 8px 8px;
}

.conn-status {
    position: fixed;
    left: 14px;
    bottom: 12px;
    z-index: 9;
    font-size: 13px;
    color: #ffe08a;
    pointer-events: none;
}

#diagnostics {
    position: fixed;
    left: 12px;
    bottom: 12px;
    z-index: 10;
    margin: 0;
    padding: 8px 10px;
    background: #141a24;
    color: #ffffff;
    font: 12px monospace;
    pointer-events: none;
}

.no-script {
    position: fixed;
    top: 40%;
    width: 100%;
    text-align: center;
}

/* Lean-paint mode for weak signage devices (Tizen 2.4 / Mali-400): flat opaque colours, zero transitions */
body.is-lean .hud-pill,
body.is-lean .hud-btn,
body.is-lean .scene-button,
body.is-lean .p-card,
body.is-lean .overlay-card,
body.is-lean .center-banner,
body.is-lean .local-hud-chip {
    background: #132020;
}
body.is-lean .hud-btn-primary { background: #1e88e5; }
body.is-lean .army-bar { background: #4a1212; }
body.is-lean .army-bar.is-incoming { background: #4a300c; }
body.is-lean .army-bar.is-retreating { background: #143a24; }
body.is-lean .defeat-card { background: #101a1e; }
body.is-lean .defeat-card.is-highscore { background: #261b06; }
body.is-lean .center-banner.is-combo { background: #382406; }
body.is-lean .rcRoomQrCodeLink {
    -webkit-transition: none;
    transition: none;
}

/* Compact landscape (e.g. 960x540 TV / tablet) */
@media (max-height: 580px) {
    .overlay-card { padding: 12px 14px; }
    .overlay-icon { width: 46px; height: 46px; }
    .overlay-title { font-size: 24px; }
    .btn-big { padding: 10px 12px; font-size: 15px; }
    .p-card { width: 146px; }
    #qrPanel { -webkit-transform: scale(0.48); transform: scale(0.48); }
    #qrPanel.is-compact { bottom: 10px; -webkit-transform: scale(0.36); transform: scale(0.36); }
}

/* Narrow portrait & smartphone viewer layout (450x960, 390x844) */
@media (max-width: 560px) {
    #hud-left-stack { top: 6px; left: 6px; right: 74px; }
    .hud-pill { padding: 3px 7px; font-size: 11px; line-height: 1.2; margin: 0 4px 4px 0; border-radius: 6px; }
    .hud-tag { padding: 1px 5px; margin-right: 5px; font-size: 10px; letter-spacing: 0.4px; }
    .hud-btn { padding: 3px 8px; font-size: 11px; line-height: 1.2; margin: 0 4px 4px 0; border-radius: 6px; }
    #scene-controls { top: 6px; right: 6px; }
    .scene-button { width: 30px; height: 30px; padding: 5px; margin: 0 0 0 4px; border-radius: 7px; }
    .scene-button svg { width: 18px; height: 18px; }
    .p-card { width: 136px; padding: 3px 6px; margin: 0 4px 3px 0; }
    .p-name { font-size: 11px; }
    .p-score { font-size: 10px; }
    .army-bar { top: 66px; width: 92%; max-width: 92%; padding: 6px 10px; }
    .army-title { font-size: 11px; letter-spacing: 0.4px; }
    .army-sub { font-size: 10px; }
    .defeat-card { top: 36%; width: 92%; max-width: 92%; padding: 12px 14px; }
    .defeat-tag, .defeat-card.is-highscore .defeat-tag { font-size: 12px; letter-spacing: 0.6px; }
    .defeat-name { font-size: 17px; }
    .defeat-score { font-size: 24px; }
    .defeat-sub { font-size: 12px; }
    .center-banner, .center-banner.is-info, .center-banner.is-combo { width: 92%; max-width: 92%; font-size: 16px; letter-spacing: 0.5px; padding: 8px 12px; top: 28%; }
    .roster-slot { width: 100%; }
    .local-controls { left: 8px; bottom: 8px; }
    .local-hud-chip { width: 224px; padding: 6px 8px; }
    #qrPanel { display: none !important; }
}
