/* Menu art and controls use the same soft, colorful materials as the islands. */
html, body { font-family: 'Nunito', Arial, sans-serif; }
#app-container { position: relative; }
#sidebar, #nickname-overlay, #music-btn { display: none !important; }
#front-screen { position: absolute; inset: 0; z-index: 1100; color: #fff; overflow: auto; font-family: 'Nunito', Arial, sans-serif; isolation: isolate; }
#front-screen[hidden] { display: none; }
#front-screen button, #front-screen input, #front-screen select { font: inherit; }
#front-screen button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
#front-screen svg { width: 22px; height: 22px; flex: 0 0 auto; }
.front-art, .front-shade { position: fixed; inset: 0; z-index: -2; pointer-events: none; }
.front-art { background: #66bce3 url('../assets/ui/menu-arena-background.webp') center / cover no-repeat; }
.front-shade { z-index: -1; background: linear-gradient(90deg, rgba(11,45,63,.7), rgba(17,52,65,.24) 48%, transparent 74%), linear-gradient(0deg, rgba(12,47,52,.52), transparent 50%); }
.front-header { display: flex; align-items: center; justify-content: space-between; padding: max(20px, env(safe-area-inset-top)) max(30px, env(safe-area-inset-right)) 0 max(30px, env(safe-area-inset-left)); gap: 20px; }
.front-brand { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 900; text-shadow: 0 2px 3px #173d59; }
.front-brand img { width: 42px; height: 42px; border: 2px solid #fff8; border-radius: 13px; box-shadow: 0 3px 9px #0c334855; }
.front-brand b { color: #ffe495; }
.front-settings { display: flex; gap: 10px; align-items: center; }
.round-button, .language-control { color: #fff; background: #163b53c9; border: 1px solid #ffffff85; box-shadow: 0 3px 0 #0b2a4180, inset 0 1px 0 #ffffff20; border-radius: 14px; }
.round-button { width: 42px; height: 42px; display: grid; place-items: center; }
.round-button.muted { opacity: .65; }
.round-button.muted:after { content: ''; position: absolute; width: 26px; height: 2px; background: #ffdb9b; transform: rotate(-45deg); }
.language-control { display: flex; align-items: center; padding: 0 10px; height: 42px; gap: 8px; }
.language-control > span { font-size: 11px; color: #d6f3f1; }
.language-control select { border: 0; background: transparent; color: #fff; font-weight: 800 !important; outline-offset: 3px; max-width: 110px; }
.language-control option { color: #163b53; background: #fff; }
.front-content { position: relative; }
.hero-content { width: min(450px, 43vw); margin: clamp(24px, 7vh, 90px) 0 32px 7vw; }
.adventure-kicker { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 12px; color: #e7fff4; letter-spacing: .5px; text-shadow: 0 2px 4px #244b54; }
.adventure-kicker > span { width: 6px; height: 6px; background: #bff196; border-radius: 50%; box-shadow: 0 0 10px #d9ff90; }
.game-title { margin: 16px 0 0; display: flex; align-items: flex-end; flex-direction: column; width: max-content; max-width: 100%; font-weight: 1000; line-height: .94; letter-spacing: -2px; filter: drop-shadow(0 5px 0 #164356) drop-shadow(0 7px 6px #0b30496e); }
.game-title > span { font-size: clamp(29px, 4.6vw, 76px); color: #fff0b6; background: linear-gradient(#fffce2 10%, #ffdf68 52%, #ffa535 94%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; -webkit-text-stroke: 1px #fff6cd; }
.game-title > strong { margin: 9px 5px 0 0; font-size: clamp(27px, 3.2vw, 49px); letter-spacing: 0; font-weight: 1000; color: #fff7d3; -webkit-text-stroke: 1px #fff7d3; }
.front-subtitle { margin: 14px 0 18px; font-weight: 700; font-size: 14px; color: #ecfcfa; text-shadow: 0 2px 3px #214553; }
.island-ticket { display: flex; align-items: center; gap: 10px; margin-bottom: 17px; padding: 8px 15px 8px 6px; width: fit-content; background: #173f55b5; border: 1px solid #caf8df7a; border-radius: 16px; box-shadow: inset 0 1px 1px #fff2; }
.island-ticket img { width: 39px; height: 39px; object-fit: contain; }
.island-ticket small { display: block; font-size: 10px; text-transform: uppercase; color: #b9ded5; letter-spacing: 1.6px; font-weight: 800; }
.island-ticket b { font-size: 16px; }
.menu-actions { display: flex; flex-direction: column; gap: 13px; max-width: 355px; }
.front-button { display: flex; justify-content: center; align-items: center; gap: 10px; min-height: 49px; border: 1.5px solid #e6fff69c; border-radius: 16px; color: #f5fff8; font-weight: 900 !important; font-size: 14px !important; background: linear-gradient(#356575ef, #1a425cf0); box-shadow: 0 4px 0 #0b2c42b5, 0 7px 13px #14394338, inset 0 2px 0 #fff2; transition: transform .15s, filter .15s; }
.front-button.primary { min-height: 60px; color: #63361d; font-size: 20px !important; border: 2px solid #fff0b7; background: linear-gradient(#ffeb9b, #ffd467 45%, #ffb83f); box-shadow: 0 5px 0 #af641c, 0 9px 20px #28413855, inset 0 2px 0 #fffbd3; text-shadow: 0 1px 0 #ffffff85; }
.front-button.primary svg { fill: currentColor; stroke: none; width: 23px; }
.front-button:hover { filter: brightness(1.08); transform: translateY(-2px); }
.front-button:active { transform: translateY(3px); }
.button-pair { display: flex; gap: 10px; }
.button-pair > button { flex: 1; font-size: 12px !important; padding: 0 8px; gap: 6px; }
.button-pair svg { width: 18px !important; }
.player-card { display: flex; align-items: center; gap: 8px; width: min(355px, 100%); padding: 9px 0; margin-top: 17px; border: none; background: none; color: #eaffee; text-shadow: 0 1px 3px #173849; text-align: left; }
.player-card > img { width: 35px; height: 35px; border-radius: 50%; background: #dcf4e9; border: 2px solid #fff9; }
.player-nickname { font-weight: 900; font-size: 14px; flex: 1; overflow: hidden; text-overflow: ellipsis; }
.edit-label { display: flex; align-items: center; gap: 7px; font-size: 11px; }
.edit-label svg { width: 15px !important; }
.welcome-card { margin-top: 24px; padding: 22px; background: linear-gradient(145deg, #173e54e8, #102f42ee); border: 1px solid #e4ffef70; border-radius: 24px; box-shadow: 0 12px 24px #1239453d, inset 0 2px 0 #fff1; }
.welcome-card h2 { margin: 0; font-size: 22px; color: #fff1bc; line-height: 1.25; }
.welcome-card p { font-size: 13px; line-height: 1.6; margin: 10px 0 19px; color: #c9e6e3; }
.welcome-card label { display: block; font-size: 12px; font-weight: 900; margin-bottom: 8px; }
.welcome-card input { display: block; box-sizing: border-box; width: 100%; height: 50px; background: #0e2b3b; border: 1.5px solid #b4ddcf; border-radius: 13px; color: #fff; padding: 0 14px; outline: none; font-weight: 700; user-select: text; }
.welcome-card input:focus { border-color: #ffe79c; box-shadow: 0 0 0 3px #ffe79c25; }
.welcome-card input[aria-invalid] { border-color: #ffb5a6; }
#front-name-hint { display: block; min-height: 16px; margin: 7px 0 17px; font-size: 10px; color: #bfd7d3; }
#front-name-form .front-button { width: 100%; min-height: 51px; font-size: 17px !important; }
.text-button { background: none; border: none; color: #d7f4e7; display: block; margin: 12px auto 0; font-size: 12px; }
.center-content { display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 28px auto; padding: 0 20px; }
.front-dialog { position: relative; width: min(410px, 80vw); padding: 25px; box-sizing: border-box; text-align: center; background: linear-gradient(150deg, #204c61f5, #123247fa); border: 2px solid #e5fff1b0; border-radius: 28px; box-shadow: 0 16px 50px #102f4460, inset 0 2px 0 #fff1; }
.front-dialog h2 { color: #fff1bc; margin: 12px 0 7px; font-size: 26px; font-weight: 900; line-height: 1.2; }
.front-dialog p { color: #c6e1df; font-size: 13px; line-height: 1.6; }
.dialog-avatar { width: 77px; height: 77px; border-radius: 24px; box-shadow: 0 4px 0 #0e2d41, 0 6px 16px #0002; border: 2px solid #fff8; }
.front-dialog .menu-actions { margin: 20px auto 0; }
.result-stats { display: flex; justify-content: space-evenly; margin: 22px 0 12px; background: #0f2a3c80; padding: 12px; border-radius: 16px; }
.result-stats small { display: block; font-size: 11px; color: #bcdbd5; }
.result-stats b { display: block; font-size: 28px; color: #ffe29a; }
#front-save-status { color: #b8d7cb; font-size: 11px; }
.ranks-dialog { width: min(680px, 88vw); }
.dialog-heading { display: flex; justify-content: center; align-items: center; gap: 12px; }
.dialog-heading svg { color: #ffd96a; width: 32px !important; height: 32px !important; }
.rank-list { min-height: 120px; max-height: 46vh; overflow: auto; padding: 5px 2px; margin: 16px 0; font-size: 13px; }
.rank-list table { width: 100%; border-collapse: collapse; }
.rank-list th { color: #adcdc7; font-size: 10px; text-transform: uppercase; letter-spacing: 1px; padding: 9px 4px; }
.rank-list td { padding: 9px 4px; border-bottom: 1px solid #ffffff18; font-weight: 800; }
.rank-list td:nth-child(3) { color: #ffe29a; }
.rank-list .your-rank { background: #95d79822; }
.load-track { height: 9px; background: #0b2839; padding: 3px; border-radius: 10px; overflow: hidden; }
#front-load-bar { height: 100%; background: linear-gradient(90deg, #a1e4b4, #ffe79a); width: 0; border-radius: 8px; transition: width .15s; }
#front-load-percent { display: block; text-align: right; font-size: 11px; color: #c3ddd3; margin-top: 7px; }
.help-backdrop { position: fixed; inset: 0; background: #0a2737b5; display: grid; place-items: center; padding: 18px; z-index: 2; }
.help-dialog { width: min(650px, 92vw); max-height: 92vh; overflow: auto; }
#help-close { position: absolute; right: 14px; top: 14px; width: 32px; height: 32px; }
.help-dialog h2 { font-size: 22px; padding: 0 16px; margin: 2px 0 20px; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; text-align: left; }
.help-grid article { display: flex; gap: 8px; padding: 12px; background: #0c2a3a77; border-radius: 15px; }
.help-grid img { width: 46px; height: 64px; object-fit: contain; }
.help-grid h3 { margin: 1px 0 5px; font-size: 13px; color: #ffeab4; }
.help-grid p { margin: 0; font-size: 11px; line-height: 1.5; }
.help-dialog > .front-button { width: min(280px, 100%); margin: 18px auto 0; min-height: 48px; font-size: 16px !important; }
.front-sparkles { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: -1; }
.front-sparkles i { position: absolute; bottom: 15%; left: 58%; width: 4px; height: 4px; background: #ffffca; border-radius: 50%; box-shadow: 0 0 9px 2px #fffba077; animation: front-float 6s infinite ease-in-out; }
.front-sparkles i:nth-child(2) { left: 85%; bottom: 25%; animation-delay: -2s; }
.front-sparkles i:nth-child(3) { left: 68%; bottom: 45%; animation-delay: -4s; }
.front-sparkles i:nth-child(4) { left: 43%; bottom: 6%; animation-delay: -1s; }
.front-sparkles i:nth-child(5) { left: 93%; bottom: 55%; animation-delay: -3s; }
@keyframes front-float { 0%,100% { opacity: 0; transform: translate(0,0); } 35%,65% { opacity: .8; } 90% { transform: translate(-12px,-55px); } }
.frontend-active #rotate-warning { display: none !important; }
#front-screen :focus-visible { outline: 3px solid #fff0af; outline-offset: 4px; }
@media (orientation: landscape) and (max-height: 590px) {
    .front-art { background-position: center top; }
    .front-header { padding-top: max(12px, env(safe-area-inset-top)); }
    .front-brand img { width: 33px; height: 33px; border-radius: 10px; }
    .round-button, .language-control { height: 35px; }
    .round-button { width: 35px; }
    .hero-content { margin-top: 12px; width: min(355px, 43vw); margin-bottom: 17px; }
    .game-title { margin-top: 11px; flex-direction: row; align-items: center; gap: 9px; }
    .game-title > strong { font-size: 22px; margin: 0; padding: 5px 8px; border-radius: 10px; background: #24536a; }
    .front-subtitle { margin: 11px 0 13px; font-size: 12px; }
    .island-ticket { margin-bottom: 14px; padding-top: 5px; padding-bottom: 5px; }
    .island-ticket b { font-size: 14px; }
    .island-ticket img { width: 30px; height: 30px; }
    .front-button.primary { min-height: 50px; font-size: 18px !important; }
    .front-button { min-height: 42px; }
    .player-card { margin-top: 12px; padding: 3px 0; }
    .welcome-card { padding: 17px; margin-top: 14px; }
    .welcome-card h2 { font-size: 18px; }
    .welcome-card p { margin: 8px 0 12px; font-size: 12px; }
    .welcome-card input { height: 42px; }
    #front-name-hint { margin-bottom: 12px; font-size: 9px; }
    .center-content { margin-top: 18px; }
    .front-dialog { padding: 19px; }
    .dialog-avatar { width: 50px; height: 50px; border-radius: 16px; }
    .front-dialog h2 { font-size: 23px; }
    .front-dialog p { margin: 9px 0; }
    .front-dialog .menu-actions { gap: 10px; margin-top: 14px; }
    .result-stats { margin: 14px 0 9px; padding: 8px; }
}
@media (orientation: portrait) {
    .front-art { background-size: auto 70%; background-position: 84% top; background-color: #174e61; }
    .front-shade { background: linear-gradient(0deg, #16394eee 0%, #143f51ea 35%, transparent 74%); }
    .front-header { padding: max(18px, env(safe-area-inset-top)) 18px 0; }
    .front-brand { font-size: 13px; gap: 7px; }
    .front-brand img { width: 33px; height: 33px; border-radius: 10px; }
    .language-control > span { display: none; }
    .round-button, .language-control { height: 36px; border-radius: 12px; }
    .round-button { width: 36px; }
    .front-settings { gap: 6px; }
    .hero-content { width: min(390px, 86vw); margin: max(210px, 34vh) auto 30px; }
    .game-title > span { font-size: clamp(35px, 8.6vw, 56px); }
    .game-title > strong { font-size: 34px; margin-top: 7px; }
    .menu-actions, .player-card { max-width: none; width: 100%; }
    .front-subtitle { font-size: 13px; }
    .center-content { margin-top: 14vh; }
    .help-grid { grid-template-columns: 1fr; gap: 9px; }
    .help-dialog { width: min(440px, 92vw); }
    .welcome-card h2 { font-size: 20px; }
    .help-dialog h2 { font-size: 19px; margin-right: 14px; }
}
@media (prefers-reduced-motion: reduce) { .front-sparkles { display: none; } #front-screen * { transition: none; } }
/* Character-attached comic bubbles: screen-space text, world-space pointer. */
.arena-dialogue {position:fixed;inset:0;z-index:60;pointer-events:none;font-family:Arial,sans-serif;}
.arena-dialogue[hidden] {display:none;}
.speech-tail {position:absolute;inset:0;width:100%;height:100%;overflow:visible;filter:drop-shadow(0 4px 2px #102c3d65);}
.speech-tail path {fill:#fff8e9;stroke:#557a85;stroke-width:2;stroke-linejoin:round;}
.speech-card {position:absolute;width:max-content;max-width:min(258px,42vw);padding:10px 15px 12px;border:2px solid #557a85;border-radius:19px;background:linear-gradient(160deg,#fff 0%,#fffdf5 65%,#f1e3c9 100%);box-shadow:inset 0 2px 0 #fff,0 4px 0 #c7b99b,0 7px 12px #12324750;color:#203d4c;}
.speech-name {display:block;margin-bottom:3px;color:#568077;font-size:10px;font-weight:700;letter-spacing:.03em;}
.speech-card p {margin:0;font-size:14px;line-height:1.35;font-weight:400;text-shadow:none;}
.campaign-badge {position:absolute;top:76px;left:50%;transform:translateX(-50%);z-index:25;pointer-events:none;max-width:78%;padding:5px 12px;border:1px solid #deefd46b;border-radius:20px;background:#12382ad9;box-shadow:0 2px 6px #10281740;color:#f7f8d8;font:12px/1.3 Arial,sans-serif;text-align:center;white-space:normal;}
.campaign-settings {display:flex;flex-wrap:wrap;justify-content:center;gap:8px;margin:10px auto;color:#fff9dc;font:12px Arial,sans-serif;}
.campaign-settings label {display:flex;align-items:center;gap:6px;padding:7px 10px;background:#102e37d9;border:1px solid #b0daca70;border-radius:12px;}
.campaign-settings select {background:#fff8e9;border:0;border-radius:6px;padding:4px;color:#173947;font:inherit;}
.campaign-settings input {accent-color:#82d9a3;}
.campaign-note {color:#e2eac8;font-size:12px;line-height:1.4;margin:6px auto;max-width:440px;}
.flag-action {margin-top:6px;}
@media(max-height:500px) {.campaign-badge{top:57px;font-size:10px;padding:3px 9px}.speech-card{padding:7px 11px 9px;max-width:230px}.speech-card p{font-size:12px}.speech-name{font-size:9px}.campaign-settings{margin:5px auto;gap:5px}.campaign-settings label{padding:4px 7px}}

/* Put campaign controls beside the menu on short landscape screens. */
@media (orientation:landscape) and (max-height:590px) {
    [data-screen="menu"] .hero-content { margin-top:8px; margin-left:5vw; width:43vw; }
    [data-screen="menu"] .adventure-kicker { display:none; }
    [data-screen="menu"] .front-subtitle { margin:8px 0; }
    [data-screen="menu"] .island-ticket { margin-bottom:10px; }
    [data-screen="menu"] .menu-actions { gap:9px; }
    [data-screen="menu"] .player-card { margin-top:8px; }
    [data-screen="menu"] .campaign-options { position:absolute;left:calc(100% + 5vw);bottom:0;width:38vw; }
    .campaign-options { padding:12px;box-sizing:border-box;border:1px solid #c6edd87a;border-radius:18px;background:#14384ddd; }
    .campaign-options .campaign-settings { margin:0;justify-content:flex-start; }
    .campaign-options .campaign-note { margin-bottom:0;font-size:11px; }
    [data-screen="pause"] .center-content,[data-screen="gameover"] .center-content { flex-direction:row;gap:22px;margin:12px auto;align-items:center; }
    [data-screen="pause"] .front-dialog,[data-screen="gameover"] .front-dialog { width:46vw;max-width:410px;padding:12px 18px; }
    .center-content .campaign-options { width:34vw;max-width:300px; }
    [data-screen="gameover"] .dialog-avatar { display:none; }
    [data-screen="gameover"] .front-dialog h2 { margin:0;font-size:21px; }
    [data-screen="gameover"] .front-dialog p { margin:6px 0;font-size:12px; }
    [data-screen="gameover"] .result-stats { margin:8px 0 5px;padding:5px; }
    [data-screen="gameover"] .result-stats b { font-size:22px; }
    [data-screen="gameover"] .menu-actions { margin-top:8px;gap:8px; }
    [data-screen="gameover"] .front-button { min-height:34px; }
    [data-screen="gameover"] .front-button.primary { min-height:42px; }
}
