/* app.css — Funny Orca
   ============================================================
   Light portal layout: fixed left category rail, sticky top bar,
   dense mixed-size tile grid. Artwork carries the colour;
   the chrome stays quiet.
   ============================================================ */

:root {
  --bg:         #FFFFFF;
  --surface:    #F5F6F9;
  --surface-2:  #EDEFF4;
  --line:       #E4E7EE;

  --ink:        #14161F;
  --ink-2:      #5F6674;
  --ink-3:      #9AA1AF;

  --brand:      #0FB9A6;
  --brand-ink:  #067D70;
  --brand-soft: #DEF8F4;
  --coral:      #FF5A5F;

  --font: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --rail:   232px;
  --header: 64px;
  --gap:    14px;
  --r:      14px;

  --shadow:    0 1px 2px rgba(20, 22, 31, .06);
  --shadow-up: 0 10px 24px rgba(20, 22, 31, .14);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 600;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
img { display: block; max-width: 100%; }

:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ============================================================
   Top bar
   ============================================================ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  height: var(--header);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 900;
  font-size: 21px;
  letter-spacing: -0.03em;
  flex-shrink: 0;
  width: calc(var(--rail) - 18px);
}

.brand svg { width: 32px; height: 32px; flex-shrink: 0; }
.brand svg .orca { animation: breach 800ms cubic-bezier(.2,.9,.25,1) both; transform-origin: 16px 20px; }
.brand em { color: var(--brand); font-style: normal; }

@keyframes breach {
  0%   { transform: translateY(10px) rotate(-16deg); opacity: 0; }
  60%  { transform: translateY(-2px) rotate(3deg);   opacity: 1; }
  100% { transform: none;                            opacity: 1; }
}

.search { position: relative; flex: 1; max-width: 460px; }

.search svg {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  stroke: var(--ink-3);
  pointer-events: none;
}

.search input {
  width: 100%;
  height: 42px;
  padding: 0 16px 0 40px;
  border-radius: 999px;
  background: var(--surface);
  border: 2px solid transparent;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
}

.search input::placeholder { color: var(--ink-3); font-weight: 600; }
.search input:focus { outline: none; background: var(--bg); border-color: var(--brand); }

.topbar .spacer { flex: 1; }

/* Stage 3 injects the account button here */
#account-slot { flex-shrink: 0; }

.btn-dark {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 40px;
  padding: 0 18px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  font-size: 14.5px;
  transition: transform 120ms, background 120ms;
}

.btn-dark:hover { background: #262A36; transform: translateY(-1px); }

/* ============================================================
   Shell + rail
   ============================================================ */

.shell {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  align-items: start;
}

.rail {
  position: sticky;
  top: var(--header);
  height: calc(100dvh - var(--header));
  overflow-y: auto;
  padding: 14px 12px 40px;
  border-right: 1px solid var(--line);
  scrollbar-width: thin;
}

.rail-title {
  margin: 6px 0 8px 12px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.rail a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--ink-2);
  font-size: 15px;
  font-weight: 700;
  transition: background 120ms, color 120ms;
}

.rail a svg { width: 20px; height: 20px; flex-shrink: 0; stroke: currentColor; }
.rail a:hover { background: var(--surface); color: var(--ink); }

.rail a[aria-current='true'] {
  background: var(--brand-soft);
  color: var(--brand-ink);
}

main { padding: 24px 22px 0; min-width: 0; }

/* ============================================================
   Sections
   ============================================================ */

.sec { margin-bottom: 34px; }

.sec-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
}

.sec-head h2 {
  margin: 0;
  font-size: 23px;
  font-weight: 900;
  letter-spacing: -0.025em;
}

.sec-head .count {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink-3);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(124px, 1fr));
  grid-auto-flow: dense;
  gap: var(--gap);
}

/* ============================================================
   Tile
   ============================================================ */

.tile {
  position: relative;
  display: block;
  aspect-ratio: 1;
  border-radius: var(--r);
  overflow: hidden;
  background: var(--tint, var(--surface-2));
  box-shadow: var(--shadow);
  transition: transform 180ms cubic-bezier(.2,.9,.25,1), box-shadow 180ms;
  will-change: transform;
}

.tile.span2 { grid-column: span 2; grid-row: span 2; border-radius: 20px; }

.tile:hover, .tile:focus-visible {
  transform: translateY(-4px);
  box-shadow: var(--shadow-up);
}

.tile .mark {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding-bottom: 14%;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: -0.04em;
  color: rgba(255, 255, 255, .95);
}

.tile.span2 .mark { font-size: 68px; }

.tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.tile .name {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  padding: 24px 9px 8px;
  background: linear-gradient(to top, rgba(10, 12, 18, .85), transparent);
  color: #fff;
  font-size: 12.5px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.tile.span2 .name { font-size: 17px; padding: 34px 14px 12px; }

/* Hover: play affordance rises from the bottom edge */
.tile .over {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(10, 12, 18, .5);
  opacity: 0;
  transition: opacity 160ms;
}

.tile:hover .over, .tile:focus-visible .over { opacity: 1; }

.tile .over .play {
  display: grid;
  place-items: center;
  width: 46px; height: 46px;
  border-radius: 50%;
  background: #fff;
  transform: translateY(8px);
  transition: transform 200ms cubic-bezier(.2,.9,.25,1);
}

.tile:hover .over .play { transform: none; }
.tile .over .play svg { width: 18px; height: 18px; margin-left: 3px; fill: var(--ink); }

.tile .badge {
  position: absolute;
  top: 8px; left: 8px;
  z-index: 3;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .95);
  color: var(--ink);
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.tile .badge.hot { background: var(--brand); color: #04322C; }

/* ============================================================
   Empty state + about + footer
   ============================================================ */

.note {
  padding: 18px 20px;
  border-radius: var(--r);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.6;
}

.note strong { color: var(--ink); font-weight: 800; }

.about {
  margin: 40px 0 0;
  padding: 28px 0 40px;
  border-top: 1px solid var(--line);
  max-width: 760px;
  color: var(--ink-2);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.7;
}

.about h2 { margin: 0 0 12px; color: var(--ink); font-size: 22px; font-weight: 900; letter-spacing: -0.02em; }
.about h3 { margin: 24px 0 8px; color: var(--ink); font-size: 16px; font-weight: 800; }
.about p  { margin: 0 0 12px; }

.foot {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 32px 22px 40px;
}

.foot-in {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, 1fr);
  gap: 28px;
  max-width: 1100px;
}

.foot h4 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.foot a, .foot li { color: var(--ink-2); font-size: 14.5px; font-weight: 700; line-height: 2; }
.foot a:hover { color: var(--brand-ink); }
.foot ul { margin: 0; padding: 0; list-style: none; }
.foot .tag { color: var(--ink-2); font-size: 14.5px; font-weight: 700; margin-top: 8px; }

/* ============================================================
   Game page
   ============================================================ */

.play-shell { display: grid; grid-template-rows: auto 1fr; height: 100dvh; }

.play-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 58px;
  padding: 0 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.play-bar h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 15px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  transition: background 120ms, color 120ms;
}

.pill:hover { background: var(--surface-2); color: var(--ink); }
.pill.on { background: #FFE9EA; color: var(--coral); }
.pill.primary { background: var(--ink); color: #fff; }
.pill.primary:hover { background: #262A36; color: #fff; }

.stage {
  position: relative;
  background: #0B0D13;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.stage iframe { width: 100%; height: 100%; border: 0; display: block; }

.stage .missing {
  padding: 30px;
  max-width: 480px;
  text-align: center;
  color: #A8B0BF;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.7;
}

.stage .missing code {
  display: inline-block;
  margin-top: 8px;
  padding: 7px 11px;
  border-radius: 8px;
  background: #191D28;
  color: #6EE7D6;
  font-size: 13px;
  font-family: ui-monospace, monospace;
}

.flash {
  position: absolute;
  bottom: 14px; right: 14px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .94);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 800;
  opacity: 0;
  transition: opacity 280ms;
  pointer-events: none;
}

.flash.show { opacity: 1; }

/* ============================================================
   Tablet / mobile
   ============================================================ */

@media (max-width: 1000px) {
  :root { --header: 58px; }

  .shell { grid-template-columns: 1fr; }
  .brand { width: auto; }
  .brand span { font-size: 18px; }

  .rail {
    position: sticky;
    top: var(--header);
    z-index: 50;
    height: auto;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 10px 14px;
    background: var(--bg);
    border-right: 0;
    border-bottom: 1px solid var(--line);
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .rail::-webkit-scrollbar { display: none; }
  .rail-title { display: none; }

  .rail a {
    flex-shrink: 0;
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--surface);
    font-size: 14px;
    white-space: nowrap;
  }

  main { padding: 18px 14px 0; }
  .sec-head h2 { font-size: 19px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
  .tile.span2 { border-radius: 16px; }
  .tile.span2 .mark { font-size: 46px; }
  .tile.span2 .name { font-size: 14px; }
  .foot-in { grid-template-columns: 1fr 1fr; gap: 22px; }
  .about { margin-top: 28px; }
}

@media (max-width: 620px) {
  .brand span { display: none; }
  .search { max-width: none; }
  .btn-dark { padding: 0 14px; }
  .grid { grid-template-columns: repeat(3, 1fr); }
  .play-bar h1 { font-size: 15px; }
}

/* Touch devices have no hover — keep the overlay out of the way */
@media (hover: none) {
  .tile:hover { transform: none; box-shadow: var(--shadow); }
  .tile .over { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ============================================================
   Account button + menu (stage 3)
   ============================================================ */

.acct { position: relative; }

.acct-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px 0 5px;
  border-radius: 999px;
  background: var(--surface);
  font-weight: 800;
  font-size: 14.5px;
  transition: background 120ms;
}

.acct-btn:hover { background: var(--surface-2); }

.acct-btn img,
.acct-btn .acct-ini {
  width: 30px; height: 30px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.acct-btn .acct-ini {
  display: grid;
  place-items: center;
  background: var(--brand);
  color: #04322C;
  font-weight: 900;
  font-size: 14px;
}

.acct-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 90;
  min-width: 232px;
  padding: 8px;
  border-radius: 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-up);
}

.acct-head {
  display: block;
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}

.acct-head strong { display: block; font-size: 14.5px; font-weight: 800; }
.acct-head span   { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-3);
                    overflow: hidden; text-overflow: ellipsis; }

.acct-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 10px;
  border-radius: 9px;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink-2);
}

.acct-item:hover { background: var(--surface); color: var(--ink); }

/* ============================================================
   Sign-in modal
   ============================================================ */

.ov {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(14, 16, 24, .5);
  backdrop-filter: blur(3px);
  animation: fade 140ms ease-out;
}

.ov[hidden] { display: none; }

@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

.sheet {
  position: relative;
  width: 100%;
  max-width: 400px;
  padding: 30px 26px 22px;
  border-radius: 22px;
  background: var(--bg);
  box-shadow: 0 24px 60px rgba(14, 16, 24, .3);
  text-align: center;
  animation: rise 200ms cubic-bezier(.2,.9,.25,1);
}

@keyframes rise { from { transform: translateY(14px); opacity: 0 } to { transform: none; opacity: 1 } }

.sheet-x {
  position: absolute;
  top: 12px; right: 14px;
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  color: var(--ink-3);
}

.sheet-x:hover { background: var(--surface); color: var(--ink); }

.sheet h2 { margin: 0 0 8px; font-size: 22px; font-weight: 900; letter-spacing: -0.025em; }

.sheet-sub {
  margin: 0 0 18px;
  color: var(--ink-2);
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.55;
}

.sheet-stats {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 18px;
}

.sheet-stats span {
  flex: 1;
  padding: 10px 4px;
  border-radius: 11px;
  background: var(--surface);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-2);
  line-height: 1.35;
}

.sheet-stats b { display: block; font-size: 17px; font-weight: 900; color: var(--ink); }

.gbtn { display: flex; justify-content: center; min-height: 44px; }

.sheet-warn {
  padding: 12px 14px;
  border-radius: 11px;
  background: #FFF4E5;
  color: #8A5A00;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.6;
}

.sheet-warn code {
  font-family: ui-monospace, monospace;
  background: rgba(0,0,0,.07);
  padding: 1px 5px;
  border-radius: 4px;
}

.sheet-later {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 10px;
  border-radius: 999px;
  color: var(--ink-2);
  font-size: 14.5px;
  font-weight: 800;
}

.sheet-later:hover { background: var(--surface); color: var(--ink); }

.sheet-fine { margin: 10px 0 0; font-size: 11.5px; font-weight: 600; color: var(--ink-3); }

/* ============================================================
   Toast
   ============================================================ */

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  z-index: 300;
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  box-shadow: var(--shadow-up);
  transform: translate(-50%, 18px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms, transform 220ms cubic-bezier(.2,.9,.25,1);
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 620px) {
  .sheet { padding: 26px 20px 18px; }
  .acct-btn { padding: 0 10px 0 5px; }
  .acct-btn .acct-name { display: none; }
  .acct-menu { right: 0; }
}

/* ============================================================
   Stage 5 — sync state + merge dialog
   ============================================================ */

.acct-sync {
  padding: 6px 10px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--brand-ink);
}

.gwait {
  display: grid;
  place-items: center;
  height: 44px;
  color: var(--ink-2);
  font-size: 14.5px;
  font-weight: 700;
}

.sheet-wide { max-width: 480px; }

.merge {
  display: grid;
  gap: 10px;
  margin: 6px 0 4px;
}

.merge-opt {
  display: block;
  width: 100%;
  padding: 15px 16px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: var(--bg);
  text-align: left;
  transition: border-color 140ms, background 140ms, transform 140ms;
}

.merge-opt:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
  transform: translateY(-1px);
}

.merge-tag {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.merge-body {
  display: block;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.55;
}

.merge-body em {
  font-style: normal;
  font-weight: 600;
  font-size: 13px;
  color: var(--ink-2);
}
