/* PolyBonk 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: #234730;
    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 & Party stack (normal flow guarantees zero overlap at every viewport width) */
#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(18, 26, 24, 0.84);
    border: 1px solid rgba(255, 255, 255, 0.26);
    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: #4fa86c;
    color: #101920;
    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: #a9c6be;
    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, 30, 36, 0.86);
    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(18, 26, 24, 0.84);
    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; }

/* Boss Health Bar */
.boss-bar {
    position: fixed;
    top: 48px;
    left: 50%;
    -webkit-transform: translateX(-50%);
    transform: translateX(-50%);
    z-index: 7;
    width: 480px;
    max-width: 86%;
    padding: 7px 12px 9px 12px;
    border-radius: 10px;
    background: rgba(34, 14, 18, 0.92);
    border: 2px solid #ff5252;
    pointer-events: none;
}

.boss-header {
    display: -webkit-flex;
    display: flex;
    -webkit-justify-content: space-between;
    justify-content: space-between;
    -webkit-align-items: baseline;
    align-items: baseline;
    margin-bottom: 6px;
}

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

.boss-hp-text {
    font-family: monospace;
    font-size: 12px;
    color: #ffd6d6;
}

.boss-track {
    height: 12px;
    border-radius: 6px;
    background: #1a0b0d;
    border: 1px solid #752727;
    overflow: hidden;
}

.boss-fill {
    width: 100%;
    height: 100%;
    background: #ef4444;
}

/* Party HUD (compact horizontal chip row directly under #hud-top inside #hud-left-stack) */
.party-hud {
    margin-top: 2px;
    width: auto;
    max-width: 100%;
    pointer-events: none;
}

.p-card {
    display: inline-block;
    vertical-align: top;
    width: 154px;
    padding: 4px 7px;
    margin: 0 5px 4px 0;
    border-radius: 8px;
    background: rgba(18, 25, 28, 0.84);
    border: 1px solid rgba(255, 255, 255, 0.22);
}

.p-card.is-upgrading {
    border-color: #ffd54f;
    background: rgba(46, 38, 16, 0.92);
}

.p-card.is-downed {
    border-color: #ef4444;
    background: rgba(52, 18, 18, 0.88);
}

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

.p-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    margin-right: 7px;
    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-meta {
    font-family: monospace;
    font-size: 11px;
    color: #ffd56b;
    margin-left: 6px;
}

.p-bars, .local-bars {
    display: -webkit-flex;
    display: flex;
    -webkit-flex-direction: column;
    flex-direction: column;
}

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

.bar-line:last-child { margin-bottom: 0; }

.bar-lbl {
    width: 18px;
    margin-right: 5px;
    font-family: monospace;
    font-size: 10px;
    font-weight: bold;
    line-height: 1;
    letter-spacing: 0.4px;
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
}

.bar-lbl-hp { color: #ff8e8e; }
.bar-lbl-xp { color: #7ed7ff; }

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

.mini-fill { height: 100%; width: 100%; }
.hp-fill { background: #ef4444; }
.xp-fill { background: #38bdf8; }

.p-status {
    margin-top: 3px;
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 0.6px;
    color: #ffe066;
    text-transform: uppercase;
}

/* Center Announcement Banner */
.center-banner {
    position: fixed;
    top: 24%;
    left: 50%;
    -webkit-transform: translateX(-50%);
    transform: translateX(-50%);
    z-index: 9;
    padding: 12px 26px;
    border-radius: 13px;
    background: rgba(18, 26, 28, 0.94);
    border: 3px solid #ffd56b;
    color: #ffffff;
    font-size: 32px;
    font-weight: bold;
    letter-spacing: 2px;
    text-transform: uppercase;
    text-align: center;
    white-space: nowrap;
    pointer-events: none;
}

.center-banner.is-boss {
    background: #5c1616;
    border-color: #ff6b6b;
}

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

/* Lobby & Results 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(18, 25, 29, 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: 60px;
    height: 60px;
    padding: 2px;
    border-radius: 12px;
    margin-right: 14px;
    background: #ffffff;
    border: 0;
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
}

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

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

.level-banner {
    padding: 8px 10px;
    margin-bottom: 12px;
    border-radius: 10px;
    background: #1d3627;
    border: 1px solid #4fa86c;
}

.level-picker-row {
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
}

.level-nav-btn {
    width: 36px;
    height: 36px;
    line-height: 32px;
    padding: 0;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.34);
    background: rgba(0, 0, 0, 0.30);
    color: #ffffff;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
}

.level-nav-btn:hover, .level-nav-btn:active {
    background: rgba(255, 255, 255, 0.20);
}

.level-picker-meta {
    -webkit-flex: 1;
    flex: 1;
    padding: 0 10px;
    min-width: 0;
}

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

.level-banner-sub {
    margin-top: 3px;
    font-size: 12px;
    color: #e4f2e8;
}

.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: #212c34;
    border: 1px solid rgba(255, 255, 255, 0.14);
}

.roster-card.is-human {
    background: #1d3c2d;
    border-color: #66d98a;
}

.roster-swatch {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    margin-right: 8px;
    border: 1px solid rgba(255, 255, 255, 0.75);
    -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: #2e8b4e;
    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: 132px;
    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: #2e9d4f; border-color: #7ee89c; }
.btn-start:hover, .btn-start:active { background: #237f3e; }
.btn-local { background: #1e7fd6; border-color: #7cc4ff; }
.btn-local:hover, .btn-local:active { background: #1665ad; }
.btn-muted { background: #344052; border-color: #5b6d87; }

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

.results-badge {
    margin: 10px 0 12px 0;
    padding: 8px 12px;
    border-radius: 8px;
    background: #204c32;
    border: 1px solid #6be394;
    color: #e9fff0;
    font-size: 13px;
    font-weight: bold;
    text-align: center;
}

.results-badge.is-loss {
    background: #542222;
    border-color: #f06e6e;
    color: #ffe5e5;
}

.results-list { margin-bottom: 12px; }

.res-row {
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    padding: 8px 10px;
    margin-bottom: 5px;
    border-radius: 8px;
    background: #212b36;
    font-size: 13px;
}

.res-meta {
    -webkit-flex: 1;
    flex: 1;
    min-width: 0;
}

.res-name { font-weight: bold; }
.res-weps { font-size: 11px; color: #9eb7ca; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.res-kills { font-family: monospace; font-weight: bold; color: #ffd56b; margin-left: 10px; }

/* Floating Touch-Anywhere Movement Reticle (appears only while dragging on #world) */
.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.50);
    background: rgba(18, 28, 34, 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: #38bdf8;
    pointer-events: none;
}

/* On-screen Local Hero Status Bar (bottom-left) */
.local-controls {
    position: fixed;
    left: 12px;
    bottom: 12px;
    z-index: 7;
    pointer-events: none;
}

.local-hud-chip {
    pointer-events: auto;
    width: 230px;
    max-width: 78vw;
    padding: 7px 10px;
    border-radius: 10px;
    background: rgba(18, 25, 30, 0.86);
    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: 5px;
}

.local-hero-tag {
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 0.7px;
    color: #ffd56b;
}

.local-exit-btn {
    padding: 3px 9px;
    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-weapons {
    margin-top: 5px;
    font-size: 11px;
    color: #c5d8e6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* On-screen 3-Choice Upgrade Modal (for Local Screen / Smartphone Viewer Play) */
.upgrade-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    -webkit-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
    z-index: 11;
    width: 660px;
    max-width: 94%;
    max-height: 88%;
    overflow-y: auto;
    padding: 18px 18px 14px 18px;
    border-radius: 16px;
    background: rgba(16, 22, 30, 0.96);
    border: 3px solid #ffd54f;
    text-align: center;
}

.upgrade-eyebrow {
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 1.5px;
    color: #ffd54f;
}

.upgrade-title {
    margin: 4px 0 14px 0;
    font-size: 26px;
}

.upgrade-cards {
    display: -webkit-flex;
    display: flex;
    -webkit-flex-wrap: wrap;
    flex-wrap: wrap;
    margin: 0 -6px;
}

.upg-card {
    -webkit-flex: 1;
    flex: 1;
    min-width: 170px;
    margin: 6px;
    padding: 14px 12px;
    border-radius: 12px;
    border: 2px solid #526885;
    background: #1f2b3b;
    color: #ffffff;
    text-align: left;
    font-family: inherit;
    cursor: pointer;
}

.upg-card:hover, .upg-card:active {
    background: #2b3c54;
    border-color: #ffffff;
}

.upg-card.rar-uncommon  { border-color: #4cd964; background: #193225; }
.upg-card.rar-rare      { border-color: #56c6ff; background: #182d42; }
.upg-card.rar-epic      { border-color: #c870ff; background: #2c1a40; }
.upg-card.rar-legendary { border-color: #ffb829; background: #422a0e; }

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

.upg-badge {
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 0.9px;
    padding: 3px 7px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.14);
    color: #ffd56b;
}

.upg-key {
    font-family: monospace;
    font-size: 12px;
    font-weight: bold;
    padding: 2px 7px;
    border-radius: 5px;
    background: rgba(0, 0, 0, 0.35);
    color: #cfe0ee;
}

.upg-name {
    font-size: 17px;
    font-weight: bold;
    margin-bottom: 6px;
}

.upg-desc {
    font-size: 13px;
    line-height: 1.35;
    color: #d0e0ec;
}

.upgrade-hint {
    margin: 10px 0 0 0;
    font-size: 12px;
    color: #a9c0d4;
}

/* 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.76;
}

.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): solid flat colours, zero alpha compositing overhead */
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,
body.is-lean .upgrade-modal,
body.is-lean .boss-bar {
    background: #141c20;
}
body.is-lean .hud-btn-primary { background: #1e88e5; }
body.is-lean .boss-bar { background: #2e1216; }
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: 140px; }
    #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-stats { font-size: 11px; }
    .stat-label { font-size: 9px; margin-right: 2px; letter-spacing: 0.4px; }
    .hud-divider { height: 10px; margin: 0 5px; }
    .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; }
    .party-hud { margin-top: 2px; }
    .p-card { width: 132px; padding: 3px 6px; margin: 0 4px 3px 0; }
    .p-name { font-size: 11px; }
    .p-meta { font-size: 10px; }
    .boss-bar { top: 60px; padding: 5px 9px 7px 9px; max-width: 94%; }
    .boss-name { font-size: 11px; }
    .center-banner { font-size: 19px; padding: 7px 14px; top: 28%; }
    .roster-slot { width: 100%; }
    .local-controls { left: 8px; bottom: 8px; }
    .local-hud-chip { width: 206px; padding: 6px 8px; }
    .upg-card { min-width: 100%; margin: 5px 0; padding: 11px 12px; }
    .upgrade-cards { margin: 0; }
    #qrPanel { display: none !important; }
}
