/* Arya's Town — big, friendly, touch-first. */

:root {
  --bg: #fff4e6;
  --ink: #3b2f4a;
  --muted: #8a7d96;
  --card: #ffffff;
  --line: #f0dfcc;
  --pink: #ff5d93;
  --blue: #4d8dff;
  --green: #23b67a;
  --gold: #ffb703;
  --shadow: 0 4px 0 rgba(59, 47, 74, 0.12), 0 8px 24px rgba(59, 47, 74, 0.08);
  --font: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  background-image: radial-gradient(circle at 20% 10%, #ffe3ee 0, transparent 40%), radial-gradient(circle at 90% 90%, #e2efff 0, transparent 45%);
  color: var(--ink);
  font-family: var(--font);
  font-size: 18px;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}
button { font-family: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: 0.4; cursor: default; }
input { font-family: inherit; user-select: text; -webkit-user-select: text; }
h1, h2, h3, h4 { margin: 0; }

.muted { color: var(--muted); }
.small { font-size: 0.8em; }
.center-text { text-align: center; }
.hidden { display: none !important; }

/* ---------- buttons ---------- */

.big, .act {
  border: none;
  border-radius: 22px;
  padding: 14px 22px;
  font-size: 1.15em;
  font-weight: 800;
  box-shadow: var(--shadow);
  transition: transform 0.08s;
  background: var(--card);
}
.big { width: 100%; padding: 18px 22px; font-size: 1.3em; }
.big:active:not(:disabled), .act:active:not(:disabled) { transform: translateY(3px); box-shadow: none; }
.btn-pink { background: var(--pink); color: #fff; }
.btn-blue { background: var(--blue); color: #fff; }
.btn-green { background: var(--green); color: #fff; }
.btn-plain { background: var(--card); color: var(--ink); }
.huge { font-size: 1.35em; padding: 16px 28px; }
.glow { animation: glow 1.2s ease-in-out infinite; outline: 4px solid var(--gold); outline-offset: 2px; }
@keyframes glow { 50% { outline-color: transparent; transform: scale(1.04); } }

.chip {
  border: 3px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
  font-size: 0.95em;
}
.chip.on { border-color: var(--pc, var(--pink)); background: #fff0f6; }
.big-chip { font-size: 1.4em; min-width: 64px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

.small-btn {
  border: 2px solid var(--line);
  background: var(--card);
  border-radius: 14px;
  padding: 6px 10px;
  font-weight: 700;
  font-size: 0.85em;
}
.icon-btn {
  border: none; background: var(--card); border-radius: 14px;
  width: 44px; height: 44px; font-size: 1.3em; box-shadow: var(--shadow);
}

/* ---------- menu screens ---------- */

.screen {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: max(20px, env(safe-area-inset-top)) 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.screen h3 { margin-top: 8px; text-align: center; }
.screen-head { display: flex; align-items: center; gap: 12px; }
.back { border: none; background: var(--card); border-radius: 14px; font-size: 1.4em; width: 52px; height: 52px; box-shadow: var(--shadow); }
.lead { text-align: center; font-size: 1.1em; margin: 0; }
.home { justify-content: center; }
.hero { text-align: center; }
.hero-mascot { font-size: 110px; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-10px) rotate(-4deg); } }
.hero h1 { font-size: 2.6em; color: var(--pink); text-shadow: 0 3px 0 #ffd0e0; }
.tag { margin: 4px 0 0; color: var(--muted); }
.menu { display: flex; flex-direction: column; gap: 12px; }

.prows { display: flex; flex-direction: column; gap: 10px; }
.prow {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border-radius: 20px; padding: 8px;
  border-left: 8px solid var(--pc); box-shadow: var(--shadow);
}
.token-pick { border: 3px solid var(--pc); background: #fff; border-radius: 50%; width: 56px; height: 56px; font-size: 1.8em; flex: none; }
.name-in { flex: 1; min-width: 0; border: 2px solid var(--line); border-radius: 14px; padding: 10px; font-size: 1.1em; font-weight: 700; color: var(--ink); }
.prow .chip { flex: none; font-size: 0.8em; padding: 8px 10px; }

.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode {
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  border: 4px solid var(--line); background: var(--card); border-radius: 20px; padding: 12px 8px;
  font-size: 0.85em;
}
.mode b { font-size: 1.3em; }
.mode.on { border-color: var(--pink); background: #fff0f6; }
.mode-icon { font-size: 2em; }
.start { margin-top: 12px; }
.code-in {
  font-size: 2.2em; text-align: center; letter-spacing: 0.3em; font-weight: 800;
  border: 4px solid var(--line); border-radius: 20px; padding: 10px; text-transform: uppercase; color: var(--ink);
}

.room-code {
  font-size: 3.2em; font-weight: 900; text-align: center; letter-spacing: 0.25em; color: var(--blue);
  background: var(--card); border-radius: 24px; padding: 12px; box-shadow: var(--shadow);
}
.lobby .chip { align-self: center; }
.lobby-list { display: flex; flex-direction: column; gap: 8px; }
.lobby-p { background: var(--card); border-radius: 16px; padding: 10px 14px; border-left: 8px solid var(--pc); font-weight: 700; display: flex; align-items: center; gap: 10px; }
.lt { font-size: 1.6em; }
.spinner, .spinner-inline { display: inline-block; animation: bob 1s ease-in-out infinite; }
.spinner { font-size: 3em; text-align: center; width: 100%; }

/* ---------- game layout ---------- */

.game {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 6px;
  padding: max(6px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}
.topbar { display: flex; align-items: center; gap: 8px; }
.brand { font-weight: 900; color: var(--pink); font-size: 1.15em; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer { font-weight: 800; font-variant-numeric: tabular-nums; }
.top-btns { display: flex; gap: 6px; }

.players { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 6px; }
.pcard {
  position: relative; background: var(--card); border-radius: 16px; padding: 6px 8px;
  border: 3px solid transparent; border-bottom: 6px solid var(--pc); min-width: 0;
  transition: transform 0.2s;
}
.pcard.turn { border-color: var(--pc); transform: translateY(-2px); box-shadow: 0 0 0 4px color-mix(in srgb, var(--pc) 25%, transparent); }
.pcard.out { opacity: 0.45; }
.pc-top { display: flex; align-items: center; gap: 4px; font-weight: 800; font-size: 0.85em; }
.pc-token { font-size: 1.4em; }
.pc-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-stars { font-size: 1.35em; font-weight: 900; font-variant-numeric: tabular-nums; }
.pc-extra { min-height: 14px; display: flex; flex-wrap: wrap; gap: 3px; align-items: center; font-size: 0.8em; }
.dot { width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, 0.15); }
.float { position: absolute; right: 8px; top: 4px; font-weight: 900; pointer-events: none; animation: floatUp 1.2s ease-out forwards; }
.float.up { color: var(--green); }
.float.down { color: #e5484d; }
@keyframes floatUp { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-30px); } }

@media (min-aspect-ratio: 5/4) {
  .game { grid-template-columns: 200px 1fr; grid-template-rows: auto 1fr; }
  .topbar { grid-column: 1 / -1; }
  .players { grid-template-columns: 1fr; align-content: start; gap: 10px; }
  .pc-stars { font-size: 1.6em; }
}

/* ---------- board ---------- */

.board-wrap { position: relative; min-height: 0; min-width: 0; }
.board { position: absolute; inset: 0; --ts: 60px; }

.tile {
  position: absolute; width: var(--ts); height: var(--ts);
  border: 3px solid rgba(59, 47, 74, 0.08); border-radius: 28%;
  background: var(--bg);
  background: radial-gradient(circle at 30% 25%, #fff 0, var(--bg) 70%);
  background-color: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 2px; overflow: visible; box-shadow: 0 3px 0 rgba(59, 47, 74, 0.12);
}
.tile { --bg: #fff; }
.tile.owned { border: calc(var(--ts) * 0.07) solid var(--oc); }
.tile.flipped { filter: grayscale(0.85); opacity: 0.75; }
.type-home { box-shadow: 0 0 0 4px var(--gold), 0 3px 0 rgba(59, 47, 74, 0.12); }
.type-adventure { background: repeating-conic-gradient(#fff3c4 0 10%, #ffe08a 10% 20%) !important; }
.type-fair { background: repeating-linear-gradient(45deg, #ffd6e7 0 8px, #fff 8px 16px) !important; }
.t-icon { font-size: calc(var(--ts) * 0.42); line-height: 1; }
.t-name { font-size: calc(var(--ts) * 0.13); font-weight: 800; line-height: 1.05; text-align: center; margin-top: 2px; max-width: 100%; }
.board.small .t-name { display: none; }
.t-price {
  position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%);
  background: #fff; border-radius: 999px; padding: 0 5px; font-size: calc(var(--ts) * 0.15); font-weight: 900;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); white-space: nowrap;
}
.t-owner {
  position: absolute; top: -8px; right: -8px; width: calc(var(--ts) * 0.36); height: calc(var(--ts) * 0.36);
  border-radius: 50%; background: var(--oc); display: grid; place-items: center; font-size: calc(var(--ts) * 0.2);
  border: 2px solid #fff;
}
.t-lvl { position: absolute; bottom: -6px; left: -6px; font-size: calc(var(--ts) * 0.26); }
.t-flip { position: absolute; top: -6px; left: -6px; font-size: calc(var(--ts) * 0.22); }

#tokens { position: absolute; inset: 0; pointer-events: none; }
.token {
  position: absolute; width: calc(var(--ts) * 0.52); height: calc(var(--ts) * 0.52); min-width: 22px; min-height: 22px;
  transform: translate(-50%, -50%); border-radius: 50%; background: #fff; border: 3px solid var(--pc);
  display: grid; place-items: center; font-size: calc(var(--ts) * 0.3); z-index: 2;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.25); transition: left 0.17s ease-out, top 0.17s ease-out;
}
.token.no-anim { transition: none; }
.token.active { z-index: 3; animation: tokenPulse 1.4s ease-in-out infinite; }
.token.gone { display: none; }
@keyframes tokenPulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--pc) 35%, transparent); } }

.center {
  position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; text-align: center; overflow: auto; padding: 6px;
}
.dice { display: flex; gap: 10px; }
.die {
  width: 54px; height: 54px; background: #fff; border-radius: 16px; display: grid;
  grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); padding: 6px;
  box-shadow: 0 4px 0 #e8c9d8, 0 6px 14px rgba(0, 0, 0, 0.12); border: 3px solid #ffd0e0;
}
.die span { display: grid; place-items: center; color: var(--pink); font-size: 13px; line-height: 1; }
.die.rolling { transform: rotate(12deg); }
.die.landed { animation: land 0.3s ease-out; }
@keyframes land { 0% { transform: scale(1.3); } 100% { transform: scale(1); } }

.guide { display: flex; align-items: flex-end; gap: 6px; max-width: 100%; }
.mascot { font-size: 2.6em; animation: bob 2.4s ease-in-out infinite; flex: none; }
.bubble {
  background: var(--card); border-radius: 20px 20px 20px 4px; padding: 10px 14px; box-shadow: var(--shadow);
  text-align: left; min-width: 0;
}
.who { display: block; font-size: 0.85em; }
.g-text { font-size: 1.1em; font-weight: 800; }
.info-icon { font-size: 1.4em; }
.tip { margin-top: 6px; font-size: 0.85em; color: #6b5a14; background: #fff7d1; border-radius: 12px; padding: 6px 8px; text-align: left; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.sub-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.warn { background: #ffe1e1; color: #a02525; border-radius: 12px; padding: 8px 10px; font-weight: 700; }

@media (max-width: 520px) {
  body { font-size: 16px; }
  .die { width: 42px; height: 42px; padding: 4px; border-radius: 12px; }
  .die span { font-size: 10px; }
  .mascot { font-size: 2em; }
  .huge { font-size: 1.15em; padding: 12px 20px; }
  .act { padding: 10px 14px; font-size: 1em; }
  .icon-btn { width: 38px; height: 38px; font-size: 1.1em; }
  .bubble { padding: 8px 10px; }
  .g-text { font-size: 1em; }
}

/* ---------- modal ---------- */

.modal {
  position: fixed; inset: 0; background: rgba(59, 47, 74, 0.45); display: grid; place-items: center;
  padding: 16px; z-index: 50; animation: fadeIn 0.15s;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal-card {
  position: relative; background: var(--bg); border-radius: 28px; padding: 22px 18px; width: min(460px, 100%);
  max-height: calc(100dvh - 32px); overflow: auto; text-align: center;
  display: flex; flex-direction: column; gap: 10px; align-items: stretch;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25); animation: pop 0.22s ease-out;
}
@keyframes pop { from { transform: scale(0.85); opacity: 0; } }
.modal-card p { margin: 0; }
.m-close { position: absolute; top: 10px; right: 10px; border: none; background: var(--card); border-radius: 50%; width: 40px; height: 40px; font-size: 1em; box-shadow: var(--shadow); }
.m-head { font-size: 1.4em; font-weight: 900; color: var(--pink); }
.m-tile {
  width: 96px; height: 96px; margin: 0 auto; border-radius: 28%; background: var(--bg); font-size: 56px;
  display: grid; place-items: center; box-shadow: var(--shadow);
}
.m-sub { color: var(--muted); font-weight: 700; }
.price-tag { font-size: 2.2em; font-weight: 900; color: var(--pink); }
.row { display: flex; gap: 10px; justify-content: center; }
.row > .act { flex: 1; }
.row.wrap { flex-wrap: wrap; }
.row.wrap > .act { flex: 1 1 45%; font-size: 0.95em; padding: 10px; }
.bid-now { font-size: 1.2em; background: var(--card); border-radius: 16px; padding: 10px; }
.pass-note { background: var(--pc); color: #fff; border-radius: 16px; padding: 10px; font-size: 1.2em; font-weight: 800; }

.adv-card {
  background: linear-gradient(160deg, #fff7d1, #ffe08a); border-radius: 24px; padding: 20px 16px;
  border: 4px dashed #f0b400; animation: flip 0.45s ease-out;
}
@keyframes flip { from { transform: rotateY(90deg); } }
.adv-head { font-weight: 900; color: #a77700; }
.adv-icon { font-size: 80px; }
.adv-text { font-size: 1.4em; font-weight: 800; }

.trade-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: left; }
.trade-cols > div { background: var(--card); border-radius: 16px; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.trade-cols h4 { text-align: center; }
.t-item { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 0.9em; }
.mini { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; background: var(--bg); flex: none; }
.t-chip { display: flex; align-items: center; gap: 6px; border: 3px solid var(--line); background: #fff; border-radius: 12px; padding: 4px 6px; font-weight: 700; font-size: 0.85em; text-align: left; }
.t-chip.on { border-color: var(--green); background: #e6f8ef; }
.stepper { display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 800; }
.step { width: 40px; height: 40px; border-radius: 50%; border: none; background: var(--blue); color: #fff; font-size: 1.3em; font-weight: 900; }

.place-row { background: var(--card); border-radius: 16px; padding: 8px; display: flex; flex-direction: column; gap: 6px; text-align: left; }
.pr-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rules { text-align: left; }
.rules p { margin: 0 0 8px; }

.confetti { font-size: 1.6em; letter-spacing: 4px; overflow: hidden; white-space: nowrap; animation: shake 0.8s ease-in-out infinite alternate; }
@keyframes shake { to { transform: translateX(-20px); } }
.win-token { font-size: 80px; width: 120px; height: 120px; margin: 0 auto; border-radius: 50%; background: #fff; border: 6px solid var(--pc); display: grid; place-items: center; animation: bob 1.4s ease-in-out infinite; }
.win-title { font-size: 2em; color: var(--pink); }
.scores { display: flex; flex-direction: column; gap: 6px; }
.score { display: grid; grid-template-columns: 28px 1fr auto auto; gap: 8px; align-items: center; background: var(--card); border-radius: 14px; padding: 8px 10px; border-left: 6px solid var(--pc); font-weight: 700; text-align: left; }

/* ---------- toast ---------- */

#toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translate(-50%, 40px);
  background: var(--ink); color: #fff; border-radius: 18px; padding: 12px 18px; font-weight: 700;
  opacity: 0; pointer-events: none; transition: all 0.25s; z-index: 60; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
