:root {
  --ink: #123044;
  --paper: #f8fafc;
  --cyan: #67e8f9;
  --gold: #f7c948;
  --green: #86efac;
  --line: rgba(248, 250, 252, 0.16);
}

* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; touch-action: manipulation; }

body {
  min-height: 100vh;
  overflow-x: hidden;
  font-family: 'Outfit', 'M PLUS Rounded 1c', sans-serif;
  color: var(--paper);
  background: linear-gradient(145deg, #07101f 0%, #123044 54%, #18312f 100%);
}

#app { width: 100%; min-height: 100vh; display: flex; justify-content: center; padding: 16px; }
.back-link {
  position: fixed; top: 15px; left: 15px; z-index: 20; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: 999px; color: var(--paper); background: rgba(7,16,31,0.72);
  text-decoration: none; font-weight: 900; font-size: 0.78rem; backdrop-filter: blur(12px);
}

.app-shell { width: min(560px, 100%); min-height: calc(100vh - 32px); display: flex; flex-direction: column; justify-content: center; gap: 12px; padding-top: 40px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.eyebrow { color: var(--gold); font-size: 0.72rem; font-weight: 900; letter-spacing: 0.12em; }
h1 { font-size: 2.05rem; line-height: 1; font-weight: 900; letter-spacing: 0; }
h1 span { color: var(--cyan); }
.wallet { min-width: 118px; padding: 10px 12px; border: 1px solid rgba(103,232,249,0.32); border-radius: 8px; background: rgba(255,255,255,0.08); text-align: right; }
.wallet span, .scorebar span { display: block; color: rgba(255,255,255,0.68); font-size: 0.68rem; font-weight: 900; letter-spacing: 0.08em; }

.scorebar, .board-wrap, .mini-guide {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.045));
  box-shadow: 0 18px 34px rgba(0,0,0,0.24);
}

.scorebar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 12px; align-items: stretch; }
.scorebar div { padding: 10px; border-radius: 8px; background: rgba(255,255,255,0.08); text-align: center; }
.scorebar b { display: block; margin-top: 4px; font-size: 1.18rem; }
button {
  border: 0; border-radius: 8px; min-height: 50px; padding: 10px 12px;
  color: var(--ink); background: var(--gold); font-family: inherit; font-size: 0.86rem; font-weight: 900;
  box-shadow: 0 8px 0 rgba(0,0,0,0.24);
}

.board-wrap { padding: 14px; }
.board {
  width: min(100%, 430px);
  aspect-ratio: 1;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(7,16,31,0.62);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: inset 0 0 36px rgba(0,0,0,0.28);
}
.tile {
  position: relative;
  min-height: 0;
  display: grid;
  place-items: center;
  color: #102033;
  background: linear-gradient(155deg, #86efac 0%, #67e8f9 58%, #f7c948 100%);
  border: 1px solid rgba(255,255,255,0.34);
  border-radius: 8px;
  box-shadow: inset 0 0 18px rgba(255,255,255,0.24), 0 7px 0 rgba(0,0,0,0.24);
  font-size: clamp(1.9rem, 8vw, 3.3rem);
  font-weight: 900;
}
.tile::after {
  content: "cat";
  position: absolute;
  right: 9px;
  bottom: 7px;
  color: rgba(16,32,51,0.48);
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}
.tile.empty {
  background: rgba(255,255,255,0.055);
  border-style: dashed;
  box-shadow: inset 0 0 22px rgba(0,0,0,0.24);
}
.tile.empty::after { content: ""; }
.message { min-height: 34px; margin-top: 12px; color: rgba(255,255,255,0.78); text-align: center; font-size: 0.92rem; font-weight: 800; }
.message.win { color: var(--gold); }
.mini-guide { padding: 14px 16px; }
.mini-guide h2 { font-size: 1.05rem; margin-bottom: 6px; }
.mini-guide p { color: rgba(255,255,255,0.76); font-size: 0.88rem; line-height: 1.55; }

@media (max-width: 560px) {
  #app { padding: 12px; }
  .app-shell { min-height: calc(100vh - 24px); justify-content: flex-start; gap: 10px; padding-top: 66px; padding-bottom: 96px; }
  h1 { font-size: 1.52rem; }
  .scorebar { grid-template-columns: repeat(3, 1fr); }
  .scorebar button { grid-column: 1 / -1; }
  .board { gap: 8px; padding: 8px; }
  .mini-guide { margin-top: 88px; }
}
