:root {
  --ink: #23315e;
  --paper: rgba(255, 250, 240, 0.92);
  --pink: #ff8fcf;
  --aqua: #6fe3ff;
  --gold: #ffd36b;
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b3a6b; font-family: "Baloo 2", "Comic Sans MS", "Chalkboard SE", "Trebuchet MS", system-ui, sans-serif; color: var(--ink); touch-action: none; overscroll-behavior: none; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
#hud.wardrobeMode { visibility: hidden; }

#topbar { position: absolute; z-index: 4; top: calc(10px + var(--safe-t)); left: calc(12px + var(--safe-l)); right: calc(12px + var(--safe-r)); display: flex; gap: 8px; align-items: center; pointer-events: none; }
#topbar > * { pointer-events: auto; }
.pill { background: var(--paper); border-radius: 999px; padding: 6px 14px; display: flex; align-items: center; gap: 6px; font-size: 20px; box-shadow: 0 4px 0 rgba(20, 40, 90, .25); border: 3px solid #fff; }
.pill b { font-size: 22px; min-width: 1ch; }
.pill .ico { font-size: 22px; }
#questWrap { flex: 1; min-width: 0; position: relative; }
.quest { width: 100%; box-sizing: border-box; min-width: 0; font-size: 17px; line-height: 1.15; cursor: pointer; }
.quest .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; box-shadow: 0 0 6px currentColor; }
.quest .caret { margin-left: auto; padding-left: 6px; font-size: 14px; opacity: .75; white-space: nowrap; }
.quest .hidden { display: none; }
.quest #questText { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quest.pulse { animation: pulse .8s ease 3; }
@keyframes pulse { 50% { transform: scale(1.06); background: #fff3b0; } }

button { font-family: inherit; color: var(--ink); cursor: pointer; }
.round { border: 3px solid #fff; background: var(--paper); border-radius: 50%; width: 54px; height: 54px; font-size: 26px; display: grid; place-items: center; box-shadow: 0 4px 0 rgba(20, 40, 90, .25); padding: 0; touch-action: none; }
.round:active, .round.on { transform: translateY(3px); box-shadow: 0 1px 0 rgba(20, 40, 90, .25); }
.round.small { width: 46px; height: 46px; font-size: 22px; flex: none; }
.round.big { width: 76px; height: 76px; font-size: 34px; background: rgba(255, 250, 240, .55); }
.round.action { background: rgba(255, 220, 120, .85); }
.round.action.ready { animation: glow 1s ease-in-out infinite alternate; }
@keyframes glow { to { box-shadow: 0 0 0 8px rgba(255, 230, 120, .5), 0 4px 0 rgba(20, 40, 90, .25); transform: scale(1.08); } }

#joyZone { position: absolute; left: 0; top: 70px; bottom: 0; width: 45%; }
#joy { position: absolute; width: 140px; height: 140px; margin: -70px 0 0 -70px; border-radius: 50%; background: rgba(255, 255, 255, .18); border: 3px solid rgba(255, 255, 255, .55); pointer-events: none; }
#joyKnob { position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 50%; background: rgba(255, 240, 250, .85); box-shadow: 0 0 18px rgba(255, 160, 220, .8); }

#rightBtns { position: absolute; right: calc(16px + var(--safe-r)); bottom: calc(16px + var(--safe-b)); display: grid; grid-template-columns: 76px 76px; grid-template-rows: 76px 76px; gap: 12px; pointer-events: none; }
#rightBtns > * { pointer-events: auto; }
#btnUp { grid-column: 2; grid-row: 1; }
#btnDown { grid-column: 2; grid-row: 2; }
#btnAct { grid-column: 1; grid-row: 2; }
#btnMic { grid-column: 1; grid-row: 1; background: rgba(255, 175, 214, .9); }
#btnMic.listening { background: #ff547e; box-shadow: 0 0 0 10px rgba(255, 84, 126, .42); animation: micPulse .7s ease-in-out infinite alternate; }
@keyframes micPulse { to { box-shadow: 0 0 0 18px rgba(255, 84, 126, .18); } }

#bubble { position: absolute; left: 50%; bottom: calc(18px + var(--safe-b)); transform: translateX(-50%); width: min(620px, 70vw); background: var(--paper); border: 4px solid #fff; border-radius: 28px; padding: 12px 16px; display: flex; align-items: center; gap: 12px; box-shadow: 0 6px 0 rgba(20, 40, 90, .3); animation: pop .25s ease; }
#bubbleFace { font-size: 52px; flex: none; }
#bubbleBody { flex: 1; }
#bubbleName { font-weight: bold; color: #c2408d; font-size: 18px; }
#bubbleText { font-size: 21px; line-height: 1.25; }
#bubbleOk { flex: none; }
@keyframes pop { from { transform: translateX(-50%) scale(.6); opacity: 0; } }

#toast { position: absolute; top: 30%; left: 50%; transform: translateX(-50%); font-size: 34px; font-weight: bold; color: #fff; text-shadow: 0 3px 0 #c2408d, 0 0 20px rgba(255, 120, 200, .9); white-space: nowrap; animation: toast 2.2s ease forwards; pointer-events: none; }
@keyframes toast { 0% { transform: translate(-50%, 20px) scale(.5); opacity: 0; } 15% { transform: translate(-50%, 0) scale(1.1); opacity: 1; } 80% { opacity: 1; } 100% { transform: translate(-50%, -30px); opacity: 0; } }

#friendPop { position: absolute; top: 18%; left: 50%; transform: translateX(-50%); background: var(--paper); border: 4px solid #fff; border-radius: 30px; padding: 10px 26px; text-align: center; animation: toast 2.6s ease forwards; pointer-events: none; }
#friendPop .emoji { font-size: 58px; }
#friendName { font-size: 24px; font-weight: bold; color: #c2408d; }
#sideQuest { position: absolute; top: calc(100% + 6px); left: 12px; right: 0; max-width: 440px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; pointer-events: auto; }
#sideQuest .side { font: inherit; font-size: 15px; line-height: 1.15; background: rgba(255, 255, 255, .96); color: inherit; text-align: left; cursor: pointer; }
#sideQuest .side .ico { font-size: 18px; }
#sideQuest .caret { margin-left: 6px; font-size: 13px; opacity: .75; white-space: nowrap; }
#sideQuest.open .choice { margin-left: 18px; font-size: 14px; background: rgba(255, 255, 255, .96); }
#sideQuest .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; box-shadow: 0 0 6px currentColor; }
.pill.tracked { opacity: 1 !important; border-color: #ffd84a; box-shadow: 0 0 0 3px rgba(255, 216, 74, .55), 0 4px 0 rgba(20, 40, 90, .25); }

.panel { position: fixed; inset: 6% 8%; background: var(--paper); border: 5px solid #fff; border-radius: 32px; padding: 18px 24px; box-shadow: 0 8px 0 rgba(20, 40, 90, .3); overflow: auto; z-index: 5; }
.panel h2 { margin: 0 0 12px; text-align: center; color: #c2408d; font-size: 28px; }
.panel > .round { position: absolute; top: 10px; right: 10px; }
#albumGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; }
.card { background: #fff; border-radius: 20px; padding: 10px 4px; text-align: center; font-size: 15px; border: 3px solid #ffd1ec; }
.card .e { font-size: 46px; display: block; }
.card { position: relative; cursor: pointer; }
.card.following { border-color: #ff6fb5; box-shadow: 0 0 0 3px rgba(255, 111, 181, .4); }
.card .tag { position: absolute; top: 4px; right: 8px; font-size: 20px; }
#albumHint { margin: -4px 0 10px; text-align: center; font-size: 15px; opacity: .8; }
.card.locked { filter: grayscale(1) brightness(.6); opacity: .5; border-color: #ccc; }
.row { display: flex; align-items: center; gap: 14px; margin: 12px auto; max-width: 420px; font-size: 30px; }
.chip { flex: 1; font-size: 20px; padding: 10px 16px; border-radius: 999px; border: 3px solid #ffd1ec; background: #fff; }
.chip:disabled { opacity: .65; cursor: wait; }
.offlineStatus { min-height: 1.3em; margin: -6px auto 4px; max-width: 420px; text-align: center; font-size: 15px; }
#wardrobe { left: 55%; right: 2%; top: 5%; bottom: 5%; inset: 5% 2% 5% 55%; background: rgba(255, 249, 240, .94); }
#wardrobeHint { text-align: center; margin: 0 0 10px; font-size: 15px; }
.dressGroup { margin: 8px 0 14px; }
.dressGroup h3 { margin: 0 0 5px; font-size: 18px; color: #754b98; }
.dressChoices { display: flex; flex-wrap: wrap; gap: 7px; }
.dressChoice { border: 3px solid #eec5e0; background: #fff; border-radius: 16px; padding: 7px 10px; font-size: 16px; min-width: 86px; }
.dressChoice.selected { background: #fff0ad; border-color: #e5a23c; }
.dressChoice:disabled { opacity: .45; filter: grayscale(1); }

#title { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(ellipse at 50% 20%, rgba(130, 230, 255, .55), rgba(10, 50, 110, .85) 70%); z-index: 10; }
.titleInner { text-align: center; color: #fff; }
#title h1 { font-size: clamp(48px, 11vw, 96px); margin: 0; line-height: .9; text-shadow: 0 5px 0 #c2408d, 0 0 30px rgba(255, 150, 220, .8); letter-spacing: 2px; }
#title h1 span { color: var(--gold); }
#tagline { font-size: 22px; margin: 14px 0 22px; text-shadow: 0 2px 4px rgba(0, 0, 0, .4); }
.start { font-size: 34px; padding: 14px 42px; border-radius: 999px; border: 5px solid #fff; background: linear-gradient(#ffb3e0, #ff7cc6); color: #fff; text-shadow: 0 2px 0 #c2408d; box-shadow: 0 7px 0 #b83a83; animation: bob 1.6s ease-in-out infinite; }
.start:active { transform: translateY(5px); box-shadow: 0 2px 0 #b83a83; }
@keyframes bob { 50% { transform: translateY(-6px); } }
.hint { opacity: .85; font-size: 16px; display: none; }
@media (orientation: portrait) { .hint { display: block; } }
#loading { position: fixed; inset: 0; display: grid; place-items: center; font-size: 60px; background: #0b3a6b; z-index: 20; animation: bob 1s infinite; }

@media (max-height: 430px) {
  .round.big { width: 64px; height: 64px; font-size: 28px; }
  #rightBtns { grid-template-columns: 64px 64px; grid-template-rows: 64px 64px; }
  .pill { padding: 4px 10px; font-size: 16px; }
  .quest { font-size: 15px; }
  #bubbleText { font-size: 18px; }
  #bubbleFace { font-size: 40px; }
  #wardrobe { inset: 3% 1% 3% 55%; padding: 9px 12px; border-radius: 18px; }
  #wardrobe h2 { font-size: 20px; margin-bottom: 3px; }
  #wardrobeHint { font-size: 12px; margin-bottom: 4px; }
  .dressGroup { margin: 3px 0 6px; }
  .dressGroup h3 { font-size: 14px; margin: 0; }
  .dressChoice { padding: 3px 7px; font-size: 13px; min-width: 69px; border-width: 2px; }
}
@media (orientation: portrait) {
  #wardrobe { inset: 55% 3% 2%; padding: 8px 12px; border-radius: 20px; }
  #wardrobe h2 { font-size: 21px; margin: 0 48px 2px; }
  #wardrobeHint { font-size: 12px; margin: 0 38px 6px; }
  .dressGroup { margin: 4px 0 8px; }
  .dressGroup h3 { font-size: 15px; margin: 0 0 3px; }
  .dressChoices { gap: 4px; }
  .dressChoice { min-width: 70px; padding: 4px 7px; font-size: 13px; border-width: 2px; }
}
body.shot #hud, body.shot #title, body.shot #loading { display: none !important; }
