*,*::before,*::after{margin:0;padding:0;box-sizing:border-box}

:root {
  --ink: #0d0d0f;
  --parchment: #e8e0d4;
  --accent: #c9a84c;
  --accent-dim: #9a7a30;
  --muted: #5a564e;
  --grid-line: rgba(201,168,76,.08);
  --cell: 20px;
}

@font-face {
  font-family: 'SystemSerif';
  src: local('Georgia'), local('Times New Roman'), local('serif');
}

html { font-size: 16px }

body {
  background: var(--ink);
  color: var(--parchment);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  position: relative;
}

/* --- ink-splash animated background --- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 30%, rgba(201,168,76,.04) 0%, transparent 70%),
    radial-gradient(ellipse 60% 80% at 80% 70%, rgba(201,168,76,.03) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.noise {
  position: fixed;
  inset: 0;
  opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 256px;
  pointer-events: none;
  z-index: 0;
}

/* --- layout --- */
.container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 720px;
  padding: 3rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  flex: 1;
}

/* --- logo / title --- */
.brand {
  text-align: center;
  margin-top: 2rem;
}

.brand h1 {
  font-family: Georgia, 'Times New Roman', serif;
  font-weight: 400;
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--parchment);
  line-height: 1.15;
}

.brand h1 span {
  display: block;
  font-size: .35em;
  letter-spacing: .4em;
  color: var(--accent);
  margin-top: .6rem;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-weight: 600;
}

.divider {
  width: 60px;
  height: 1px;
  background: var(--accent);
  opacity: .5;
}

.tagline {
  text-align: center;
  color: var(--muted);
  font-size: .95rem;
  line-height: 1.6;
  max-width: 420px;
}

/* --- game area --- */
.game-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: calc(var(--cell) * 20);
}

.game-label {
  font-size: .75rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--muted);
}

.game-label.game-switch {
  cursor: pointer;
  transition: color .2s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.game-label.game-switch:hover {
  color: var(--accent);
}

/* --- game dropdown selector --- */
.game-dropdown {
  position: absolute;
  z-index: 200;
  min-width: 140px;
  padding: .35rem 0;
  background: #1a1a1e;
  border: 1px solid rgba(201,168,76,.2);
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  list-style: none;
}

.game-dropdown.hidden {
  display: none;
}

.game-dropdown-item {
  padding: .45rem 1rem;
  font-size: .75rem;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}

.game-dropdown-item:hover {
  background: rgba(201,168,76,.08);
  color: var(--parchment);
}

.game-dropdown-item.active {
  color: var(--accent);
}

.score {
  font-variant-numeric: tabular-nums;
  font-size: .85rem;
  color: var(--accent);
  font-weight: 600;
}

.canvas-wrap {
  position: relative;
  border: 1px solid rgba(201,168,76,.15);
  border-radius: 4px;
  overflow: hidden;
  background: rgba(0,0,0,.3);
  box-shadow: 0 0 60px rgba(201,168,76,.04);
  touch-action: none;
}

canvas {
  display: block;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .8rem;
  background: rgba(13,13,15,.82);
  backdrop-filter: blur(4px);
  transition: opacity .3s;
  z-index: 2;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.3rem;
  color: var(--parchment);
  letter-spacing: .06em;
}

.overlay-sub {
  font-size: .78rem;
  color: var(--muted);
  letter-spacing: .08em;
}

.btn {
  margin-top: .5rem;
  padding: .55rem 1.8rem;
  border: 1px solid var(--accent-dim);
  border-radius: 3px;
  background: transparent;
  color: var(--accent);
  font-size: .8rem;
  letter-spacing: .15em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .2s, color .2s;
}

.btn:hover, .btn:focus-visible {
  background: var(--accent);
  color: var(--ink);
  outline: none;
}

.controls-hint {
  font-size: .7rem;
  color: var(--muted);
  letter-spacing: .08em;
  opacity: .7;
}

.controls-hint--mobile { display: none }

@media (hover: none) and (pointer: coarse) {
  .controls-hint--desktop { display: none }
  .controls-hint--mobile { display: block }
}

/* --- fullscreen button (mobile only) --- */
.fs-btn {
  display: none;
}

@media (hover: none) and (pointer: coarse) {
  .fs-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid rgba(201,168,76,.2);
    border-radius: 4px;
    background: transparent;
    color: var(--muted);
    font-size: 1rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color .2s, border-color .2s;
    flex-shrink: 0;
    margin-left: .5rem;
  }

  .fs-btn:hover, .fs-btn:active {
    color: var(--accent);
    border-color: var(--accent-dim);
  }
}

/* --- fullscreen game mode --- */
.game-fs {
  position: fixed !important;
  inset: 0;
  z-index: 100;
  background: var(--ink);
  margin: 0 !important;
  padding: 0 !important;
  justify-content: center;
  overflow: hidden;
}

.game-fs .game-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  max-width: none;
  padding: .5rem 1rem;
  z-index: 101;
  background: rgba(13,13,15,.85);
}

.game-fs .canvas-wrap {
  max-width: none !important;
  width: 100%;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.game-fs .canvas-wrap canvas {
  width: 100% !important;
  height: auto !important;
}

.game-fs .controls-hint {
  display: none !important;
}

/* --- game visibility toggle --- */
.game-hidden {
  display: none !important;
}

/* --- footer --- */
footer {
  position: relative;
  z-index: 1;
  padding: 1.5rem;
  text-align: center;
  font-size: .7rem;
  color: var(--muted);
  letter-spacing: .1em;
  opacity: .6;
}
