/* Owlcade "Nocturne" theme, the same tokens as the hub (owlcade.com). Gold stays the game's own
   colour: the logo, coins and anything that is about the gold. */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('fonts/inter.woff2') format('woff2');
}

:root {
  --color-bg: #161826;
  --color-surface: #232532;
  --color-text: #e9e9ed;
  --color-accent: #9184d9;
  --color-divider: color-mix(in srgb, #e9e9ed 16%, transparent);

  --color-neutral-100: #f3f5fe;
  --color-neutral-200: #e4e7f5;
  --color-neutral-300: #cfd3e5;
  --color-neutral-400: #b2b6ca;
  --color-neutral-500: #9397ab;
  --color-neutral-800: #3f424d;
  --color-neutral-900: #292b31;

  --color-accent-100: #f5f4ff;
  --color-accent-300: #d2cefd;
  --color-accent-400: #b5abfc;
  --color-accent-800: #423a6a;

  --gold: #ffc629;
  --gold-soft: #ffe27a;
  --teal: #4fd1c5;
  --danger: #e07a73;

  --glass: rgba(22, 24, 38, 0.88);
  --font: 'Inter', system-ui, sans-serif;
  --radius-md: 8px;
  --radius-lg: 14px;
  --shadow-sm: 0 0 0 1px #3f424d;
  --gutter: clamp(18px, 5vw, 64px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; background: var(--color-bg); color: var(--color-text); font-family: var(--font); font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
#game { position: fixed; inset: 0; display: block; cursor: crosshair; image-rendering: pixelated; touch-action: none; }
h1 { font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; margin: 0 0 8px; color: var(--gold); }
h2 { font-size: 11px; font-weight: 500; letter-spacing: 0.1em; margin: 14px 0 8px; color: var(--color-accent); text-transform: uppercase; }
.gold { color: var(--gold); }
button { font-family: inherit; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--color-accent) 30%, transparent); }

/* — buttons, as on the hub — */
.btn, .big {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: 14px; font-weight: 500;
  padding: 9px 18px; border-radius: var(--radius-md);
  border: 1px solid var(--color-divider); background: transparent;
  color: var(--color-text); text-decoration: none; cursor: pointer;
}
.btn:hover, .big:hover { background: rgba(233, 233, 237, 0.07); }
.btn-primary, .big { color: var(--color-accent); border-color: var(--color-accent); }
.btn-primary:hover, .big:hover { background: rgba(145, 132, 217, 0.12); color: var(--color-accent-300); }
.big.alt { color: var(--color-text); border-color: var(--color-divider); }
.big.alt:hover { background: rgba(233, 233, 237, 0.07); color: var(--color-text); }
.btn-sm { font-size: 13px; font-weight: 400; padding: 5px 12px; }
.btn:disabled, .big:disabled { opacity: 0.5; cursor: default; }
.big { display: flex; margin: 16px auto 0; }
.link { background: none; border: none; color: var(--color-neutral-400); font: inherit; font-size: 12px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 0; }
.link:hover { color: var(--color-accent); }

/* — in-game panels — */
.panel { position: fixed; background: var(--glass); border: 1px solid var(--color-divider); border-radius: var(--radius-md); padding: 10px 12px; font-size: 12px; user-select: none; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.row { display: flex; justify-content: space-between; gap: 16px; line-height: 1.65; }
.row span { color: var(--color-neutral-500); }
.row b { font-weight: 500; }
.row.coins b { color: var(--gold-soft); font-size: 16px; font-weight: 600; }

#hud { top: 12px; left: 12px; min-width: 210px; pointer-events: none; }
#hover { margin-top: 6px; min-height: 1.4em; color: #cfe8d4; }
#hint { color: var(--gold); }
#effects { color: #ff9f7a; }
#effects:empty { display: none; }
#compass-wrap { display: flex; align-items: center; gap: 8px; margin-top: 6px; color: var(--gold); }
#compass-wrap[hidden] { display: none; }
#compass { font-size: 22px; line-height: 1; width: 24px; text-align: center; transition: transform 0.1s linear; }

#side { top: 12px; right: 12px; bottom: 12px; width: 224px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--color-neutral-800) transparent; }
#side h2:first-of-type { margin-top: 4px; }
#minimap { width: 186px; height: 186px; display: block; border: 1px solid var(--color-divider); border-radius: 4px; image-rendering: pixelated; }
#upgrades, #bots { display: flex; flex-direction: column; gap: 5px; }
.shop-item { display: grid; grid-template-columns: 1fr auto; gap: 1px 6px; text-align: left; font: inherit; font-size: 11px; color: inherit; background: var(--color-surface); border: 1px solid transparent; box-shadow: var(--shadow-sm); border-radius: 6px; padding: 6px 8px; cursor: pointer; transition: box-shadow 0.15s; }
.shop-item:hover:not(:disabled) { box-shadow: 0 0 0 1px var(--color-accent); }
.shop-item:disabled { opacity: 0.5; cursor: default; }
.shop-item .name { font-weight: 600; color: var(--color-neutral-100); }
.shop-item .lvl { color: var(--color-neutral-500); text-align: right; }
.shop-item .desc { color: var(--color-neutral-500); grid-column: 1 / -1; }
.shop-item .eff { color: #a9d8b8; }
.shop-item .cost { color: var(--gold-soft); text-align: right; font-weight: 500; }
.shop-item.bot .name { color: var(--teal); }
#legend { display: grid; gap: 2px; }
.gem-row { display: grid; grid-template-columns: 14px 1fr auto; gap: 6px; align-items: center; font-size: 11px; color: var(--color-neutral-300); }
.gem-row i { width: 12px; height: 12px; display: block; border-radius: 2px; }
.gem-row b { color: var(--color-neutral-400); font-weight: 400; }

#toast { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); background: var(--color-surface); color: var(--color-text); box-shadow: 0 0 0 1px var(--gold), 0 8px 24px rgba(0, 0, 0, 0.5); padding: 7px 16px; border-radius: var(--radius-md); font-size: 13px; font-weight: 500; pointer-events: none; z-index: 20; max-width: calc(100vw - 32px); text-align: center; }
.overlay { position: fixed; inset: 0; background: rgba(12, 13, 22, 0.72); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; z-index: 10; }
.overlay[hidden] { display: none; }
.card { background: var(--color-bg); box-shadow: var(--shadow-sm), 0 24px 64px rgba(0, 0, 0, 0.55); border-radius: var(--radius-lg); padding: 26px 30px; max-width: 460px; font-size: 14px; line-height: 1.55; color: var(--color-neutral-200); }
.card h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; text-transform: none; text-align: center; color: var(--color-text); margin-bottom: 12px; }
.card h1.gold { color: var(--gold); }
.card p { margin: 0 0 10px; }
.card ul { padding-left: 18px; margin: 8px 0; }
.card li { margin-bottom: 4px; }
.card b { color: var(--color-text); font-weight: 600; }
.card b.gold { color: var(--gold); }
.card .row { font-size: 14px; }
kbd { display: inline-block; font: inherit; font-size: 11px; font-weight: 500; border: 1px solid var(--color-neutral-800); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; margin-right: 2px; background: var(--color-surface); }

/* --- Touch controls --- */
#joystick, #shop-btn, .mob { display: none; }
.touch .mob { display: list-item; }
.touch .desk { display: none; }
.touch #joystick { display: block; position: fixed; left: calc(24px + env(safe-area-inset-left)); bottom: calc(24px + env(safe-area-inset-bottom)); width: 120px; height: 120px; border-radius: 50%; background: rgba(233, 233, 237, 0.06); border: 2px solid rgba(233, 233, 237, 0.18); touch-action: none; z-index: 5; }
#knob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: rgba(145, 132, 217, 0.55); border: 2px solid rgba(210, 206, 253, 0.8); pointer-events: none; }
#game, #joystick { -webkit-tap-highlight-color: transparent; }

/* --- Small screens: shop becomes a slide-in panel --- */
@media (max-width: 820px) {
  #shop-btn { display: block; position: fixed; top: calc(10px + env(safe-area-inset-top)); right: calc(10px + env(safe-area-inset-right)); z-index: 7; font: inherit; font-weight: 600; font-size: 13px; letter-spacing: 0.06em; background: var(--glass); color: var(--color-accent); border: 1px solid var(--color-accent); border-radius: var(--radius-md); padding: 8px 12px; }
  #side { top: 0; right: 0; bottom: 0; width: min(300px, 86vw); border-radius: 0; border-width: 0 0 0 1px; padding-top: calc(52px + env(safe-area-inset-top)); transform: translateX(100%); transition: transform 0.2s ease; z-index: 6; }
  #side.open { transform: none; }
  .shop-item { padding: 8px; font-size: 12px; }
  #hud { top: calc(8px + env(safe-area-inset-top)); left: calc(8px + env(safe-area-inset-left)); min-width: 0; max-width: 60vw; padding: 6px 8px; font-size: 11px; }
  #hud h1 { font-size: 10px; margin-bottom: 4px; }
  .wide-only { display: none; }
  .card { margin: 12px; padding: 20px; max-height: 90dvh; overflow-y: auto; }
}
button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
@media (max-width: 820px) {
  #hover:empty, #hint:empty { display: none; }
}

/* --- Tables and tabs (leaderboard, stats) --- */
#submit-status, #board-status { min-height: 1.2em; margin: 8px 0 0; color: var(--color-neutral-400); text-align: center; }
.actions { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }
.actions .big { margin: 0; }
#board-table, #recent-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; text-align: left; }
#board-table th, #recent-table th { color: var(--color-neutral-500); font-size: 11px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; text-align: left; border-bottom: 1px solid var(--color-divider); padding: 6px 4px; }
#board-table td, #recent-table td { padding: 6px 4px; border-bottom: 1px solid rgba(233, 233, 237, 0.06); }
#board-table td:nth-child(3) { color: var(--gold-soft); }
#board-table tr.me td { background: rgba(145, 132, 217, 0.14); }
#board .card { width: min(480px, 94vw); }
#board-tabs { display: flex; border-bottom: 1px solid var(--color-divider); margin-top: 8px; }
#board-tabs button { flex: 1; background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -1px; padding: 7px 2px; font: inherit; font-size: 12px; font-weight: 500; color: var(--color-neutral-500); cursor: pointer; white-space: nowrap; }
#board-tabs span { align-self: center; padding: 0 8px 0 2px; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-neutral-800); }
#board-tabs button:hover { color: var(--color-text); }
#board-tabs button.on { color: var(--color-accent); border-bottom-color: var(--color-accent); }

.badge { color: var(--teal); font-size: 10px; margin-left: 4px; }

/* --- Minimap (always visible) and the game menu --- */
#map { left: 12px; bottom: 12px; padding: 6px; display: flex; flex-direction: column; gap: 6px; }
#minimap { width: 160px; height: 160px; }
.map-bar { display: flex; gap: 6px; }
#pause-btn { display: flex; align-items: center; justify-content: center; gap: 7px; flex: 1; font: inherit; font-size: 11px; font-weight: 500; letter-spacing: 0.06em; background: var(--color-surface); color: var(--color-neutral-300); border: 1px solid var(--color-divider); border-radius: 6px; padding: 5px 7px; cursor: pointer; }
#pause-btn:hover { border-color: var(--color-accent); color: var(--color-text); }
/* two bars, drawn with borders (no icon font, no inline style) */
#pause-btn i { display: block; width: 8px; height: 10px; border-left: 3px solid currentColor; border-right: 3px solid currentColor; }
.map-bar:has(#game-btn:not([hidden])) #pause-btn { flex: none; }
.map-bar:has(#game-btn:not([hidden])) #pause-btn span { display: none; }
#game-btn { flex: 1; font: inherit; font-size: 11px; font-weight: 500; letter-spacing: 0.06em; background: var(--color-surface); color: var(--color-neutral-300); border: 1px solid var(--color-divider); border-radius: 6px; padding: 5px 7px; cursor: pointer; text-align: left; }
#game-btn:hover { border-color: var(--color-accent); }
#rally-btn { font: inherit; font-size: 11px; font-weight: 500; letter-spacing: 0.06em; background: var(--color-surface); color: var(--color-neutral-300); border: 1px solid var(--color-divider); border-radius: 6px; padding: 5px 7px; cursor: pointer; }
#rally-btn[hidden] { display: none; }
#rally-btn:hover { border-color: var(--color-accent); }
#rally-btn.on { border-color: var(--gold); color: var(--gold); }
#bots-share { margin: -2px 0 8px; font-size: 11px; color: var(--color-neutral-400); }
#bots-share:empty { display: none; }
#game-btn b { color: var(--gold); letter-spacing: 0.2em; }
#game-btn small { float: right; color: var(--color-neutral-500); letter-spacing: 0; }
#game-btn[hidden] { display: none; }
#game-menu .card { width: min(400px, 94vw); }
#pause .card, #feedback .card { width: min(420px, 94vw); }
#pause .note, #feedback .note { color: var(--color-neutral-400); font-size: 13px; text-align: center; margin: 0 0 6px; }
#pause .note:empty { display: none; }
#pause-who { text-align: center; color: var(--color-neutral-300); font-size: 13px; }
#pause-who::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--teal); margin-right: 8px; vertical-align: 1px; }
#pause-resume { width: 100%; margin: 12px 0 0; }
.pause-buttons { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.pause-buttons .big { margin: 0; padding: 8px 6px; font-size: 13px; }
.pause-buttons .big[hidden] { display: none; }
#pause-game { color: var(--gold-soft); letter-spacing: 0.04em; }
#pause .card > .row { font-size: 13px; }
#pause #legend { grid-template-columns: 1fr 1fr; gap: 3px 16px; margin-top: 4px; }
#feedback-text { display: block; width: 100%; resize: vertical; min-height: 120px; font: inherit; font-size: 14px; line-height: 1.5; background: var(--color-surface); color: var(--color-text); caret-color: var(--color-accent); border: 1px solid var(--color-divider); border-radius: var(--radius-md); padding: 10px 12px; -webkit-user-select: text; user-select: text; }
#feedback-text:focus-visible { border-color: var(--color-accent); outline: none; }
#feedback-text::placeholder { color: var(--color-neutral-500); }
.feedback-foot { display: flex; justify-content: space-between; gap: 12px; margin: 6px 0 0 !important; font-size: 12px; color: var(--color-neutral-400); min-height: 1.4em; }
.feedback-foot small { color: var(--color-neutral-500); }
#game-menu h1 span { color: var(--gold-soft); letter-spacing: 0.18em; }
#game-menu .note { color: var(--color-neutral-400); font-size: 12px; text-align: center; margin: 0 0 10px; }
.menu-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.menu-buttons .big { margin: 0; padding: 8px 6px; font-size: 13px; }
#mine-settings[hidden] { display: none; }
.menu-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 6px 0; color: var(--color-neutral-300); }
.seg { display: flex; overflow: hidden; border: 1px solid var(--color-divider); border-radius: var(--radius-md); }
.seg button { font: inherit; font-size: 12px; background: transparent; color: var(--color-neutral-400); border: none; padding: 5px 10px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--color-divider); }
.seg button.on { background: var(--color-accent-800); color: var(--color-accent-100); }
#mine-max { font: inherit; font-size: 12px; background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-divider); border-radius: 6px; padding: 4px 6px; }
#mine-players { display: grid; gap: 6px; }
.mine-player { display: grid; grid-template-columns: 10px 1fr auto auto; gap: 8px; align-items: center; font-size: 13px; }
.mine-player i { width: 10px; height: 10px; display: block; border-radius: 2px; }
.mine-player.off { opacity: 0.5; }
.mine-player b { color: var(--color-neutral-400); font-weight: 400; }
.mine-player .tools { display: flex; gap: 8px; }
.mine-player .owner { color: var(--gold); margin-left: 4px; }
@media (max-width: 820px) {
  /* the HUD (coins) sits top left and the map top right: toasts go to the bottom, clear of both */
  #toast { top: auto; bottom: calc(24px + env(safe-area-inset-bottom)); }
  #rally-btn { font-size: 10px; padding: 4px; }
  #map { left: auto; bottom: auto; top: calc(52px + env(safe-area-inset-top)); right: calc(10px + env(safe-area-inset-right)); padding: 4px; gap: 4px; }
  #minimap { width: 104px; height: 104px; }
  #game-btn { font-size: 10px; padding: 4px; text-align: center; }
  /* a pause button as wide as the map, big enough for a thumb, with the game code under it */
  .map-bar { flex-direction: column; gap: 4px; }
  #pause-btn, .map-bar:has(#game-btn:not([hidden])) #pause-btn { flex: none; min-height: 40px; font-size: 13px; font-weight: 600; padding: 6px; }
  .map-bar:has(#game-btn:not([hidden])) #pause-btn span { display: inline; }
  #pause-btn i { width: 10px; height: 12px; }
  .pause-buttons .big { min-height: 44px; font-size: 14px; }
  #game-btn small { display: none; }
}
.mastery { color: var(--gold); font-size: 10px; margin-left: 4px; }

/* ======================================================================
   Main menu: title top left, choices bottom left, a dig in the background
   ====================================================================== */
.menu { position: fixed; inset: 0; z-index: 10; overflow: hidden; background: var(--color-bg); }
.menu[hidden], .menu [hidden] { display: none !important; }
#menu-bg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.menu-shade {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(to right, rgba(22, 24, 38, 0.92) 0%, rgba(22, 24, 38, 0.6) 32%, rgba(22, 24, 38, 0.1) 62%, rgba(22, 24, 38, 0.35) 100%),
    linear-gradient(to top, rgba(22, 24, 38, 0.85) 0%, transparent 40%),
    radial-gradient(ellipse 60% 70% at 64% 46%, transparent 40%, rgba(22, 24, 38, 0.55) 100%);
}

.menu-top {
  position: absolute; top: 0; right: 0; z-index: 2;
  padding: calc(clamp(14px, 3vw, 28px) + env(safe-area-inset-top)) calc(var(--gutter) + env(safe-area-inset-right)) 0 0;
}
.brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 500; font-size: 16px; letter-spacing: -0.02em;
  color: var(--color-neutral-300); text-decoration: none;
}
.brand:hover { color: var(--color-text); }
/* FR/EN toggle next to the brand (shared with the hub through the owlcade-lang cookie) */
.menu-top { display: flex; align-items: center; gap: 16px; }
.menu-top .seg.lang button { min-height: 0; font-size: 12px; padding: 5px 9px; }
.brand-eyes { display: flex; gap: 4px; }
.brand-eyes span { width: 7px; height: 7px; border-radius: 50%; background: var(--color-accent); }
/* shown on gold-beta.owlcade.com only (account.js) */
.beta-tag {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em; padding: 3px 7px; border-radius: 4px;
  color: var(--color-accent); border: 1px solid var(--color-accent);
}
.beta-tag[hidden] { display: none; }

.menu-main {
  position: relative; z-index: 1; height: 100%;
  display: flex; flex-direction: column;
  padding: calc(clamp(40px, 9vh, 96px) + env(safe-area-inset-top)) var(--gutter) calc(clamp(28px, 7vh, 72px) + env(safe-area-inset-bottom)) calc(var(--gutter) + env(safe-area-inset-left));
  max-width: 560px;
}
.logo {
  margin: 0; color: var(--color-text); text-transform: uppercase;
  font-size: clamp(38px, 5.6vw, 72px); font-weight: 700; line-height: 0.95; letter-spacing: -0.035em;
  display: flex; flex-wrap: wrap; column-gap: 0.25em;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.5);
}
.logo-gold { position: relative; color: var(--gold); padding-right: 0.42em; }
/* the gold gem: a glowing square tucked against the word, like the figure in a game logo */
.logo-gold i {
  position: absolute; right: 0; top: 0.08em; width: 0.3em; height: 0.3em;
  background: var(--gold); box-shadow: 0 0 0.35em rgba(255, 216, 74, 0.7), inset -0.06em -0.06em 0 rgba(160, 100, 0, 0.45);
}
#home-who { margin: 18px 0 0; color: var(--color-neutral-300); font-size: 15px; max-width: 420px; text-wrap: pretty; }
#home-who:empty { display: none; }
#home-current { margin: 6px 0 0; color: var(--color-neutral-500); font-size: 13px; }
#home-current:empty { display: none; }

.menu-list { margin-top: auto; padding-top: 28px; display: flex; flex-direction: column; gap: 14px; }
.menu-items { display: flex; flex-direction: column; }
.menu-item {
  position: relative; display: block; width: min(360px, 100%);
  font: inherit; font-size: clamp(16px, 1.6vw, 19px); font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; text-align: left;
  color: var(--color-neutral-300); background: transparent; border: 0; border-radius: 4px;
  padding: 7px 14px 7px 14px; margin-left: -14px; cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.menu-item:hover, .menu-item:focus-visible, .menu-item.on {
  color: var(--color-text);
  background: linear-gradient(to right, rgba(233, 233, 237, 0.16), rgba(233, 233, 237, 0.06));
  outline: none;
}
.menu-item::before {
  content: ''; position: absolute; left: 0; top: 7px; bottom: 7px; width: 2px; border-radius: 2px;
  background: var(--color-accent); opacity: 0; transition: opacity 0.12s;
}
.menu-item:hover::before, .menu-item:focus-visible::before, .menu-item.on::before { opacity: 1; }
.menu-item:disabled { opacity: 0.5; cursor: wait; }
#home-resume, #home-continue { color: var(--gold-soft); }
#home-status { min-height: 1.3em; margin: 10px 0 0; color: var(--danger); font-size: 13px; }
#home-status:empty { min-height: 0; margin: 0; }

.menu-foot { display: flex; align-items: center; gap: 12px; margin-top: 18px; font-size: 13px; color: var(--color-neutral-400); }
.menu-foot:has(#home-me:empty) { display: none; }
#home-me::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--teal); margin-right: 8px; vertical-align: 1px; }
#home-me:empty::before { display: none; }

.menu-legal { position: absolute; right: calc(var(--gutter) + env(safe-area-inset-right)); bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 1; margin: 0; }
.legal-links { font-size: 11px; text-align: center; margin: 14px 0 0; }
.legal-links a { color: var(--color-neutral-500); margin: 0 6px; text-decoration: none; }
.legal-links a:hover { color: var(--color-accent); }

/* the modal: Play, Mastery, Stats, over a dimmed menu (a click outside closes it) */
.menu.panel-open::after { content: ''; position: absolute; inset: 0; z-index: 2; background: rgba(12, 13, 22, 0.6); }
.menu-panel {
  position: absolute; z-index: 3; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(440px, calc(100vw - 2 * var(--gutter)));
  max-height: calc(100dvh - 140px); overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--color-neutral-800) transparent;
  background: var(--glass); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: var(--shadow-sm), 0 24px 64px rgba(0, 0, 0, 0.5);
  border-radius: var(--radius-lg); padding: 20px 24px 24px; font-size: 14px; color: var(--color-neutral-200);
  animation: panel-in 0.18s ease-out;
}
@keyframes panel-in { from { opacity: 0; transform: translate(-50%, -47%); } }
.menu-panel header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.menu-panel h2 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.02em; text-transform: none; color: var(--color-text); }
.menu-panel h3 { margin: 18px 0 8px; font-size: 11px; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-accent); }
.menu-panel .tab > h3:first-child, .menu-panel #home-parties > h3 { margin-top: 4px; }
.menu-panel .note { color: var(--color-neutral-400); font-size: 13px; line-height: 1.55; margin: 12px 0 10px; text-wrap: pretty; }
.panel-back { display: inline-block; font: inherit; font-size: 20px; line-height: 1; color: var(--color-neutral-300); background: none; border: 1px solid var(--color-divider); border-radius: var(--radius-md); padding: 5px 10px 7px; cursor: pointer; }
.panel-back:hover { color: var(--color-text); background: rgba(233, 233, 237, 0.07); }
.panel-open .menu-legal { display: none; }

#mine-join { display: flex; gap: 8px; }
#mine-code-input {
  flex: 1; min-width: 0; font: inherit; font-size: 18px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.35em; text-align: center;
  background: var(--color-surface); color: var(--color-text); caret-color: var(--color-accent);
  border: 1px solid var(--color-divider); border-radius: var(--radius-md); padding: 8px 10px;
  -webkit-user-select: text; user-select: text;
}
#mine-code-input::placeholder { color: var(--color-neutral-800); }
#mine-code-input:focus-visible { border-color: var(--color-accent); outline: none; }
#mine-quick { width: 100%; margin-top: 8px; }
#home-local { display: block; margin: 8px 0 0; }
#home-party-list { display: flex; flex-direction: column; gap: 6px; }
.party-row { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; text-align: left; font-size: 12px; background: var(--color-surface); box-shadow: var(--shadow-sm); border-radius: var(--radius-md); padding: 8px 10px; }
.party-row b { color: var(--gold); letter-spacing: 0.2em; font-weight: 600; font-size: 14px; }
.party-row span { color: var(--color-neutral-400); font-size: 12px; }

#home-materials { display: flex; flex-direction: column; gap: 6px; }
.mastery-row { display: grid; grid-template-columns: 14px 1fr auto auto; gap: 10px; align-items: center; font-size: 13px; text-align: left; }
.mastery-row i { width: 12px; height: 12px; display: block; border-radius: 2px; }
.mastery-row .name { color: var(--color-text); }
.mastery-row .name small { display: block; color: var(--color-neutral-500); font-size: 11px; }
.mastery-row b { color: var(--color-neutral-400); font-weight: 400; }
.master-btn { font: inherit; font-size: 12px; font-weight: 500; background: transparent; color: var(--color-accent); border: 1px solid var(--color-accent); border-radius: 6px; padding: 4px 8px; cursor: pointer; min-width: 96px; }
.master-btn:hover:not(:disabled) { background: rgba(145, 132, 217, 0.12); color: var(--color-accent-300); }
.master-btn:disabled { opacity: 0.4; cursor: default; border-color: var(--color-divider); color: var(--color-neutral-400); }

.stat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 8px; }
.stat-grid div { background: var(--color-surface); box-shadow: var(--shadow-sm); border-radius: var(--radius-md); padding: 8px 4px; text-align: center; }
.stat-grid b { display: block; color: var(--gold-soft); font-size: 15px; font-weight: 600; }
.stat-grid span { color: var(--color-neutral-500); font-size: 10px; }
#recent-table tr.won td { color: var(--gold); }
#recent-table tr.active td:nth-child(2) { color: var(--teal); }
#stats-empty { text-align: center; margin: 14px 0; }

/* Phones and narrow windows: the title on top, the menu below it, panels full screen */
@media (max-width: 820px) {
  .menu-shade {
    background:
      linear-gradient(to top, rgba(22, 24, 38, 0.97) 0%, rgba(22, 24, 38, 0.88) 45%, rgba(22, 24, 38, 0.2) 75%, rgba(22, 24, 38, 0.6) 100%);
  }
  .menu-main { max-width: none; padding-top: calc(64px + env(safe-area-inset-top)); }
  .menu-top { left: 0; padding-left: calc(var(--gutter) + env(safe-area-inset-left)); }
  .logo { font-size: clamp(34px, 11vw, 56px); }
  #home-who { font-size: 14px; margin-top: 12px; }
  /* big buttons a thumb can hit, laid over the dig; the page never scrolls */
  .menu-list { gap: 10px; padding-top: 16px; }
  .menu-items { gap: 10px; }
  .menu-item {
    width: 100%; margin: 0; min-height: clamp(46px, 7.2dvh, 60px); padding: 0 20px;
    font-size: 17px; font-weight: 600; letter-spacing: 0.05em;
    color: var(--color-text); background: rgba(35, 37, 50, 0.84); box-shadow: var(--shadow-sm);
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); border-radius: 12px;
  }
  .menu-item::before { display: none; }
  .menu-item:hover, .menu-item:focus-visible, .menu-item.on { background: rgba(63, 66, 77, 0.92); }
  .menu-play, .menu-play:hover, .menu-play:focus-visible, .menu-play.on { background: var(--color-accent); color: #14121f; box-shadow: 0 8px 28px rgba(145, 132, 217, 0.35); font-size: 19px; }
  .menu-main { overflow: hidden; padding-bottom: calc(44px + env(safe-area-inset-bottom)); }
  .menu-foot { margin-top: 12px; }
  .menu-legal { left: calc(var(--gutter) + env(safe-area-inset-left)); right: auto; text-align: left; }
  .menu-legal a:first-child { margin-left: 0; }
  .menu-panel {
    inset: 0; top: 0; right: 0; transform: none; width: auto; max-height: none; border-radius: 0;
    padding: calc(16px + env(safe-area-inset-top)) calc(var(--gutter) + env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) calc(var(--gutter) + env(safe-area-inset-left));
    background: var(--color-bg);
    animation: none; overflow: hidden; display: flex; flex-direction: column;
  }
  .menu-panel .tab { overflow-y: auto; min-height: 0; }
  .panel-back { padding: 8px 14px 10px; }
  .menu-panel .btn { min-height: 48px; font-size: 15px; }
  #mine-new, #mine-join-btn { background: var(--color-accent); color: #14121f; font-weight: 600; padding: 0 22px; }
  #mine-code-input { min-height: 52px; font-size: 22px; }
  .seg button { min-height: 46px; font-size: 15px; padding: 0 18px; }
  .mastery-row { font-size: 13px; }
  .master-btn { min-height: 34px; }
  #recent-table tbody tr:nth-child(n+6) { display: none; }
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 420px) {
  #recent-table th:nth-child(5), #recent-table td:nth-child(5) { display: none; }
}
@media (max-height: 560px) and (min-width: 821px) {
  .menu-item { padding-top: 4px; padding-bottom: 4px; font-size: 15px; }
  .logo { font-size: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  .menu-panel { animation: none; }
}

/* Play modal */
.btn.wide { width: 100%; margin-top: 6px; }
.new-game { display: flex; gap: 8px; align-items: stretch; }
.new-game .seg { flex: 1; }
.new-game .seg button { flex: 1; }
.new-game .btn { flex: none; }
#mine-join { display: flex; gap: 8px; }

/* Touch: the joystick shows where the finger lands; the shop opens from the right edge */
.touch #joystick { display: none; left: 0; top: 0; bottom: auto; transform: translate(-50%, -50%); pointer-events: none; }
.touch #joystick.on { display: block; }
@media (max-width: 820px) {
  /* Fixed size and a rotated label: Safari sizes a button around vertical (writing-mode) text
     wrongly, which pushed half of the tab off the right edge. */
  #shop-btn {
    display: flex; align-items: center; justify-content: center;
    top: 50%; left: auto; right: env(safe-area-inset-right); transform: translateY(-50%);
    width: 42px; height: 104px; padding: 0; border-right: 0; border-radius: 12px 0 0 12px;
    font-size: 15px; letter-spacing: 0.18em;
  }
  #shop-btn span { display: block; white-space: nowrap; transform: rotate(90deg); margin-right: -0.18em; }
  #side { padding-top: calc(16px + env(safe-area-inset-top)); }
  body:has(#side.open) #shop-btn { right: min(300px, 86vw); }
  #map { top: calc(8px + env(safe-area-inset-top)); right: calc(8px + env(safe-area-inset-right)); }
}
