:root {
  --ink: #1f2a2e; --muted: #5d676b; --card: rgba(255,250,242,.94); --paper: #fffaf2;
  --accent: #1b8a5a; --accent-2: #e8f5ee; --bad: #b3122a; --gold: #f2a900; --shadow: 0 2px 8px rgba(0,0,0,.18);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #9fd3f0; color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; user-select: none; touch-action: none; }
#app canvas { display: block; }
[hidden] { display: none !important; }
button { font-family: inherit; color: inherit; }

/* ---- HUD ---- */
#hud { position: fixed; top: max(8px, env(safe-area-inset-top)); left: 8px; right: 92px; display: flex; gap: 5px; flex-wrap: wrap; pointer-events: none; }
.card { background: var(--card); border-radius: 10px; padding: 4px 8px; font-size: 12px; box-shadow: var(--shadow); }
.card b { font-size: 14px; }
.card.who { min-width: 170px; }
.card.combo b { color: var(--bad); }
.bar { height: 7px; background: #e5dccd; border-radius: 4px; overflow: hidden; margin-top: 3px; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.bar.bad i { background: var(--bad); }
#topbtns { position: fixed; top: max(8px, env(safe-area-inset-top)); right: 8px; display: flex; gap: 6px; }
#topbtns button { width: 38px; height: 38px; border-radius: 10px; border: 0; background: var(--card); font-size: 17px; cursor: pointer; box-shadow: var(--shadow); }

/* ---- loadout ---- */
#loadout { position: fixed; bottom: max(10px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  display: flex; gap: 6px; max-width: calc(100vw - 16px); }
.wbtn { position: relative; overflow: hidden; background: var(--card); border: 3px solid transparent; border-radius: 12px;
  padding: 4px 4px 3px; width: 74px; cursor: pointer; text-align: center; box-shadow: var(--shadow); }
.wbtn .em { font-size: 24px; display: block; line-height: 1.1; }
.wbtn small { display: block; font-size: 10px; line-height: 1.15; height: 23px; overflow: hidden; color: var(--muted); }
.wbtn.sel { border-color: var(--accent); background: var(--accent-2); }
.wbtn.empty { opacity: .45; }
.wbtn .cd { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(0,0,0,.18); pointer-events: none; }
.wbtn .ch { position: absolute; top: 2px; right: 4px; font-size: 11px; color: var(--bad); }

/* ---- floating text ---- */
.bubble { position: fixed; transform: translate(-50%, -100%); background: #fff; border-radius: 12px; padding: 6px 10px;
  font-weight: 700; font-size: 14px; max-width: 70vw; text-align: center; pointer-events: none; box-shadow: var(--shadow); z-index: 5; }
.bubble:after { content: ''; position: absolute; left: 50%; bottom: -8px; margin-left: -7px; border: 7px solid transparent; border-top-color: #fff; border-bottom: 0; }
.float { position: fixed; transform: translate(-50%, -50%); font-weight: 800; color: #fff; text-shadow: 0 2px 3px #000;
  pointer-events: none; font-size: 20px; animation: up 1s forwards; white-space: nowrap; z-index: 6; }
@keyframes up { to { transform: translate(-50%, -170%); opacity: 0; } }
.psay { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); background: #1f2a2e; color: #fff; padding: 8px 14px;
  border-radius: 14px; font-weight: 700; font-size: 15px; max-width: 86vw; text-align: center; pointer-events: none; z-index: 6;
  animation: psay 2.4s forwards; }
@keyframes psay { 0% { opacity: 0; transform: translate(-50%, 10px); } 10%, 85% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }
#toast { position: fixed; top: 32%; left: 50%; transform: translate(-50%, -50%); background: rgba(27,138,90,.95); color: #fff;
  font-size: 20px; font-weight: 800; padding: 12px 20px; border-radius: 14px; pointer-events: none; text-align: center; z-index: 7; max-width: 90vw; }
#toast small { font-weight: 600; font-size: 13px; }
#flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 8; }
#flash.go { animation: flash .5s; }
@keyframes flash { 0% { opacity: .95; } 100% { opacity: 0; } }

/* ---- screens ---- */
#screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: linear-gradient(to bottom, rgba(20,25,28,.05), rgba(20,25,28,.55)); z-index: 10; overflow-y: auto; touch-action: pan-y; }
.panel { background: var(--paper); border-radius: 18px; padding: 18px; width: 100%; max-width: 440px; box-shadow: 0 10px 40px rgba(0,0,0,.3);
  margin: auto; text-align: center; max-height: calc(100vh - 32px); overflow-y: auto; }
.panel.wide { max-width: 620px; }
.panel.sheet, .panel.home { margin: auto auto 0; max-height: 62vh; }
.panel h1.title { margin: 0; font-size: 32px; letter-spacing: -.5px; color: var(--bad); }
.panel h2 { margin: 0; font-size: 21px; }
.tag { margin: 2px 0 10px; color: var(--muted); }
.quote { font-style: italic; color: var(--bad); font-weight: 600; margin: 8px 0; }
.small { font-size: 12px; color: var(--muted); }
.pills { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin: 6px 0 10px; }
.pill { background: #f1e9da; border-radius: 20px; padding: 4px 10px; font-size: 13px; font-weight: 600; }
.note { background: #fff4cc; border-radius: 10px; padding: 8px 10px; font-size: 13px; margin: 8px 0; }
.daily { display: flex; align-items: center; gap: 10px; justify-content: space-between; text-align: left; background: #e8f1fb;
  border-radius: 12px; padding: 10px 12px; font-size: 13px; margin-bottom: 10px; }
.daily .done { font-weight: 700; color: var(--accent); white-space: nowrap; }
.btn { border: 0; background: var(--accent); color: #fff; font-size: 15px; font-weight: 700; padding: 10px 16px; border-radius: 10px; cursor: pointer; }
.btn.big { width: 100%; font-size: 18px; padding: 14px; margin-top: 6px; }
.btn.sm { font-size: 13px; padding: 7px 12px; white-space: nowrap; }
.btn.alt { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.btn.danger { background: var(--bad); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; text-align: left; }
.head h2 { flex: 1; }
.back { border: 0; background: #f1e9da; width: 36px; height: 36px; border-radius: 10px; font-size: 22px; cursor: pointer; line-height: 1; }
.link { border: 0; background: none; color: var(--accent); text-decoration: underline; cursor: pointer; font-size: 13px; margin-top: 6px; }

.ogrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.ocard { border: 0; background: #f6efe2; border-radius: 12px; padding: 10px 8px; cursor: pointer; text-align: center; display: flex; flex-direction: column; gap: 2px; align-items: center; }
.ocard .em { font-size: 34px; }
.ocard small { color: var(--muted); font-size: 11px; }
.ocard .st { font-size: 11px; font-weight: 700; color: var(--accent); margin-top: 2px; }
.ocard.boss { background: #2b2d42; color: #fff; }
.ocard.boss small { color: #cfd3dd; }
.ocard.boss .st { color: #ffd23f; }
.ocard.locked { opacity: .5; cursor: not-allowed; }

details { text-align: left; background: #f6efe2; border-radius: 12px; padding: 8px 12px; margin: 8px 0; }
summary { cursor: pointer; font-weight: 700; }
.looks { margin-top: 6px; }
.lrow { display: grid; grid-template-columns: 1fr 32px 90px 32px; align-items: center; gap: 4px; margin: 4px 0; font-size: 14px; }
.lval { text-align: center; text-transform: capitalize; }
.mini { border: 0; background: #fff; border-radius: 8px; height: 30px; font-size: 18px; cursor: pointer; }
.sw { display: inline-block; width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px #ccc; vertical-align: middle; }

.slots { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 4px 0 10px; }
.slot { border: 0; background: var(--accent-2); border-radius: 10px; padding: 6px 2px; font-size: 22px; cursor: pointer; }
.slot small { display: block; font-size: 10px; color: var(--muted); }
.slot.empty { display: flex; align-items: center; justify-content: center; background: #eee; color: #aaa; }
.tabs { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 6px; }
.tab { border: 0; background: #f1e9da; border-radius: 10px; padding: 6px 8px; font-size: 20px; cursor: pointer; flex: 0 0 auto; min-width: 66px; }
.tab small { display: block; font-size: 10px; }
.tab.on { background: var(--accent); color: #fff; }
.witems { display: grid; gap: 6px; text-align: left; }
.witem { display: grid; grid-template-columns: 40px 1fr auto; gap: 8px; align-items: center; background: #f6efe2; border-radius: 12px; padding: 8px 10px; }
.witem .em { font-size: 28px; text-align: center; }
.witem small { display: block; color: var(--muted); font-size: 12px; }
.witem.notown .em { filter: grayscale(.6); }

.srow { display: flex; justify-content: space-between; align-items: center; gap: 10px; text-align: left; padding: 10px 0; border-bottom: 1px solid #eee3d1; font-size: 14px; }
.srow small { color: var(--muted); }
.thumb { width: 48px; height: 32px; object-fit: cover; border-radius: 6px; vertical-align: middle; margin-right: 6px; }
.about { margin-top: 12px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 10px 0; }
.stats div { background: #f6efe2; border-radius: 10px; padding: 8px 2px; }
.stats b { display: block; font-size: 20px; }
.stats small { color: var(--muted); font-size: 11px; }
.coins { font-size: 20px; font-weight: 800; color: #9a6b00; margin: 6px 0; }
.coins small { font-size: 12px; font-weight: 600; color: var(--muted); }

@media (max-width: 480px) {
  .card.who { min-width: 0; flex: 1 1 100%; }
  .wbtn { width: 64px; }
  .wbtn small { font-size: 9px; }
  .panel { padding: 14px; }
}

/* ---- shown only when the browser has no WebGL ---- */
.nogl { max-width: 420px; margin: 18vh auto 0; padding: 20px; background: var(--paper); border-radius: 18px;
  text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.2); }
.nogl h1 { margin: 0 0 8px; color: var(--bad); }
.nogl p { color: var(--muted); }
.foot { margin: 10px 0 0; }
.foot a { color: var(--accent); }
