@import url('https://fonts.googleapis.com/css2?family=Space+Mono:ital,wght@0,400;0,700;1,400&display=swap');

/* ── Reset & Base ─────────────────────────────────── */
html, body {
  margin: 0;
  padding: 0;
  background: #0c0e14;
  color: #7a8494;
  font-family: 'Space Mono', 'JetBrains Mono', 'Roboto Mono', monospace;
  font-size: 18px;
}
body { margin: 50px 0 60px; }

/* ── Outer flex wrapper ───────────────────────────── */
.forge-wrapper {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: flex-start;
  align-items: flex-start;
  -webkit-justify-content: center;
  justify-content: center;
  gap: 18px;
}

/* ── Heading ──────────────────────────────────────── */
.heading:after { content: ""; display: block; clear: both; }

h1.title {
  font-size: 36px;
  font-weight: 700;
  margin: 0;
  display: block;
  float: left;
  color: #00e8ff;
  text-shadow: 0 0 20px rgba(0,232,255,0.4);
  letter-spacing: -0.02em;
  line-height: 1.05;
}

/* ── Score containers ─────────────────────────────── */
@-webkit-keyframes move-up {
  0%   { top: 25px;  opacity: 1; }
  100% { top: -50px; opacity: 0; }
}
@keyframes move-up {
  0%   { top: 25px;  opacity: 1; }
  100% { top: -50px; opacity: 0; }
}

.scores-container { float: right; text-align: right; }

.score-container, .best-container {
  position: relative;
  display: inline-block;
  background: #0d1018;
  border: 1px solid #1e2330;
  padding: 20px 14px 6px;
  font-size: 20px;
  font-weight: 700;
  border-radius: 5px;
  color: #00e8ff;
  margin-top: 8px;
  margin-left: 8px;
  text-align: center;
  min-width: 66px;
  box-sizing: border-box;
  line-height: 1;
  vertical-align: top;
  font-family: inherit;
}
.score-container::before {
  content: ">_ SCORE";
  position: absolute;
  top: 5px; left: 0; right: 0;
  font-size: 8px;
  letter-spacing: 0.12em;
  text-align: center;
  color: #3a4258;
}
.best-container::before {
  content: ">_ BEST";
  position: absolute;
  top: 5px; left: 0; right: 0;
  font-size: 8px;
  letter-spacing: 0.12em;
  text-align: center;
  color: #3a4258;
}
.score-container .score-addition, .best-container .score-addition {
  position: absolute;
  right: 6px;
  top: 20px;
  color: #2099B1;
  font-size: 13px;
  line-height: 1;
  font-weight: bold;
  z-index: 100;
  -webkit-animation: move-up 600ms ease-in both;
  animation: move-up 600ms ease-in both;
}

/* ── Typography ───────────────────────────────────── */
p { margin-top: 0; margin-bottom: 10px; line-height: 1.65; }
a { color: #2099B1; font-weight: bold; text-decoration: underline; cursor: pointer; }
strong.important { text-transform: uppercase; color: #d0d8e8; }
hr { border: none; border-bottom: 1px solid #1e2330; margin: 20px 0; }

/* ── Container ────────────────────────────────────── */
.container { width: 500px; -webkit-flex-shrink: 0; flex-shrink: 0; }

/* ── Fade-in ──────────────────────────────────────── */
@-webkit-keyframes fade-in { 0% { opacity: 0; } 100% { opacity: 1; } }
@keyframes fade-in { 0% { opacity: 0; } 100% { opacity: 1; } }

/* ── Active circuit board glow ────────────────────── */
@-webkit-keyframes board-glow {
  0%, 100% {
    box-shadow:
      0 0 0 1px rgba(0,232,255,0.12),
      0 0 22px rgba(0,232,255,0.28),
      0 0 55px rgba(0,232,255,0.08),
      inset 0 0 40px rgba(0,232,255,0.03);
    border-color: rgba(0,232,255,0.28);
  }
  50% {
    box-shadow:
      0 0 0 1px rgba(0,232,255,0.60),
      0 0 42px rgba(0,232,255,0.56),
      0 0 95px rgba(0,232,255,0.22),
      inset 0 0 55px rgba(0,232,255,0.08);
    border-color: rgba(0,232,255,0.75);
  }
}
@keyframes board-glow {
  0%, 100% {
    box-shadow:
      0 0 0 1px rgba(0,232,255,0.12),
      0 0 22px rgba(0,232,255,0.28),
      0 0 55px rgba(0,232,255,0.08),
      inset 0 0 40px rgba(0,232,255,0.03);
    border-color: rgba(0,232,255,0.28);
  }
  50% {
    box-shadow:
      0 0 0 1px rgba(0,232,255,0.60),
      0 0 42px rgba(0,232,255,0.56),
      0 0 95px rgba(0,232,255,0.22),
      inset 0 0 55px rgba(0,232,255,0.08);
    border-color: rgba(0,232,255,0.75);
  }
}

@-webkit-keyframes arc-sweep {
  from { -webkit-transform: rotate(0deg); transform: rotate(0deg); }
  to   { -webkit-transform: rotate(360deg); transform: rotate(360deg); }
}
@keyframes arc-sweep {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ── Game board ───────────────────────────────────── */
.game-container {
  margin-top: 18px;
  position: relative;
  padding: 15px;
  cursor: default;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  touch-action: none;
  background: #13161e;
  border: 1px solid rgba(0,232,255,0.28);
  border-radius: 8px;
  width: 500px;
  height: 500px;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  -webkit-animation: board-glow 3.5s ease-in-out infinite;
  animation: board-glow 3.5s ease-in-out infinite;
}

/* PCB corner node glows — active via pads */
.game-container::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 7px;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at  2%  2%,  rgba(0,232,255,0.14) 0%, transparent 18%),
    radial-gradient(circle at 98%  2%,  rgba(0,232,255,0.11) 0%, transparent 15%),
    radial-gradient(circle at  2% 98%,  rgba(0,232,255,0.11) 0%, transparent 15%),
    radial-gradient(circle at 98% 98%,  rgba(0,232,255,0.14) 0%, transparent 18%),
    radial-gradient(ellipse at 50% 50%, rgba(0,120,160,0.04) 0%, transparent 70%);
}

/* Sweeping current arcs — two opposed charge nodes rotating */
.game-container::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 7px;
  z-index: 0;
  pointer-events: none;
  background: conic-gradient(
    from 0deg at 50% 50%,
    transparent           0deg,
    transparent          72deg,
    rgba(0,232,255,0.07) 85deg,
    rgba(0,210,248,0.13) 90deg,
    rgba(0,232,255,0.07) 95deg,
    transparent         108deg,
    transparent         252deg,
    rgba(0,232,255,0.05) 265deg,
    rgba(0,210,248,0.10) 270deg,
    rgba(0,232,255,0.05) 275deg,
    transparent         288deg,
    transparent         360deg
  );
  -webkit-animation: arc-sweep 8s linear infinite;
  animation: arc-sweep 8s linear infinite;
}

.game-container .game-message {
  display: none;
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  background: rgba(12,14,20,0.92);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  z-index: 100;
  text-align: center;
  border-radius: 8px;
  -webkit-animation: fade-in 800ms ease 1200ms both;
  animation: fade-in 800ms ease 1200ms both;
}
.game-container .game-message p {
  font-size: 36px;
  font-weight: 700;
  height: 44px;
  line-height: 44px;
  margin-top: 210px;
  color: #d0d8e8;
  letter-spacing: 0.04em;
}
.game-container .game-message .lower { display: block; margin-top: 44px; }
.game-container .game-message a {
  display: inline-block;
  background: transparent;
  border: 1px solid #2a3040;
  border-bottom: 3px solid #161c28;
  border-radius: 4px;
  padding: 0 18px;
  text-decoration: none;
  color: #2099B1;
  height: 38px;
  line-height: 38px;
  margin: 0 5px;
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  -webkit-transition: border-color 0.12s, background 0.12s;
  transition: border-color 0.12s, background 0.12s;
}
.game-container .game-message a:hover { border-color: #00e8ff; background: rgba(0,232,255,0.07); }
.game-container .game-message a.keep-playing-button { display: none; }
.game-container .game-message.game-won { background: rgba(0,8,16,0.94); }
.game-container .game-message.game-won p { color: #00e8ff; text-shadow: 0 0 28px rgba(0,232,255,0.8); }
.game-container .game-message.game-won a.keep-playing-button { display: inline-block; }
.game-container .game-message.game-won,
.game-container .game-message.game-over { display: block; }

/* ── Grid ─────────────────────────────────────────── */
.grid-container { position: absolute; z-index: 1; }
.grid-row { margin-bottom: 15px; }
.grid-row:last-child { margin-bottom: 0; }
.grid-row:after { content: ""; display: block; clear: both; }
.grid-cell {
  width: 106.25px;
  height: 106.25px;
  margin-right: 15px;
  float: left;
  border-radius: 4px;
  background: rgba(0,232,255,0.025);
  border: 1px solid rgba(0,232,255,0.08);
  box-shadow: inset 0 0 10px rgba(0,232,255,0.04);
}
.grid-cell:last-child { margin-right: 0; }

/* ── Tile container ───────────────────────────────── */
.tile-container { position: absolute; z-index: 2; }
.tile, .tile .tile-inner { width: 107px; height: 107px; }

/* ── Tile positions ───────────────────────────────── */
.tile.tile-position-1-1 { -webkit-transform: translate(0px,   0px);   transform: translate(0px,   0px);   }
.tile.tile-position-1-2 { -webkit-transform: translate(0px,   121px); transform: translate(0px,   121px); }
.tile.tile-position-1-3 { -webkit-transform: translate(0px,   242px); transform: translate(0px,   242px); }
.tile.tile-position-1-4 { -webkit-transform: translate(0px,   363px); transform: translate(0px,   363px); }
.tile.tile-position-2-1 { -webkit-transform: translate(121px, 0px);   transform: translate(121px, 0px);   }
.tile.tile-position-2-2 { -webkit-transform: translate(121px, 121px); transform: translate(121px, 121px); }
.tile.tile-position-2-3 { -webkit-transform: translate(121px, 242px); transform: translate(121px, 242px); }
.tile.tile-position-2-4 { -webkit-transform: translate(121px, 363px); transform: translate(121px, 363px); }
.tile.tile-position-3-1 { -webkit-transform: translate(242px, 0px);   transform: translate(242px, 0px);   }
.tile.tile-position-3-2 { -webkit-transform: translate(242px, 121px); transform: translate(242px, 121px); }
.tile.tile-position-3-3 { -webkit-transform: translate(242px, 242px); transform: translate(242px, 242px); }
.tile.tile-position-3-4 { -webkit-transform: translate(242px, 363px); transform: translate(242px, 363px); }
.tile.tile-position-4-1 { -webkit-transform: translate(363px, 0px);   transform: translate(363px, 0px);   }
.tile.tile-position-4-2 { -webkit-transform: translate(363px, 121px); transform: translate(363px, 121px); }
.tile.tile-position-4-3 { -webkit-transform: translate(363px, 242px); transform: translate(363px, 242px); }
.tile.tile-position-4-4 { -webkit-transform: translate(363px, 363px); transform: translate(363px, 363px); }

/* ── Tile base ────────────────────────────────────── */
.tile {
  position: absolute;
  -webkit-transition: 100ms ease-in-out;
  transition: 100ms ease-in-out;
  -webkit-transition-property: -webkit-transform;
  transition-property: transform;
}

.tile .tile-inner {
  border-radius: 5px;
  background: #0d1018;
  text-align: center;
  font-weight: 700;
  font-family: inherit;
  z-index: 10;
  position: relative;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  gap: 4px;
  overflow: hidden;
}

/* Pseudo-element base — used for all texture overlays */
.tile .tile-inner::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  z-index: 0;
  pointer-events: none;
}

/* Text layers always on top of textures */
.tile .sf-main,
.tile .sf-sub,
.tile .sf-byte-dots {
  position: relative;
  z-index: 2;
}

/* Main glyph / value */
.tile .sf-main {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}

/* "[value] [TIER]" label */
.tile .sf-sub {
  font-size: 9px;
  opacity: 0.52;
  line-height: 1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ══════════════════════════════════════════════════
   TIER 1 — BIT (#32383E)
   Flat matte charcoal: top-down overhead light
   Icon: binary toggle "01"
   ══════════════════════════════════════════════════ */
.tile.tile-2 .tile-inner {
  background: linear-gradient(180deg, #2e3338 0%, #1e2226 70%, #191d21 100%);
  color: #4a5058;
  border: 1px solid #32383E;
}
.tile.tile-2 .sf-main {
  font-size: 22px;
  letter-spacing: 6px;
  color: #4a5058;
}
.tile.tile-2 .sf-sub { opacity: 0.3; }

/* BIT binary toggle — b0 dim, b1 accent */
.tile.tile-2 .sf-main .b0 { color: #2a2f34; }
.tile.tile-2 .sf-main .b1 { color: #5c6470; }

/* ══════════════════════════════════════════════════
   TIER 2 — BYTE (#4A525A)
   Brushed metallic: vertical grain, radial behind 9-dot
   Icon: 9-dot 3×3 grid
   ══════════════════════════════════════════════════ */
.tile.tile-4 .tile-inner {
  background-color: #383f47;
  background-image:
    radial-gradient(ellipse at 50% 44%, rgba(255,255,255,0.08) 0%, transparent 60%),
    repeating-linear-gradient(
      180deg,
      rgba(255,255,255,0.042) 0px,
      rgba(255,255,255,0.042) 2px,
      transparent 2px,
      transparent 7px
    );
  color: #8fa5b8;
  border: 1px solid #4A525A;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.14),
    inset 0 -1px 0 rgba(0,0,0,0.22);
}

/* 9-dot 3×3 bit-register grid */
.tile.tile-4 .sf-byte-dots {
  display: grid;
  grid-template-columns: repeat(3, 9px);
  grid-template-rows: repeat(3, 9px);
  gap: 4px;
}
.tile.tile-4 .sf-byte-dots span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #7090a8;
  box-shadow: 0 0 3px rgba(112,144,168,0.5);
}

/* ══════════════════════════════════════════════════
   TIER 3 — KB (#2099B1)
   Cyan glassmorphism: semi-transparent + blur
   Icon: microchip traces (PCB SVG)
   ══════════════════════════════════════════════════ */
.tile.tile-8 .tile-inner {
  background: rgba(10, 55, 75, 0.78);
  color: #2099B1;
  border: 1px solid rgba(32,153,177,0.7);
  box-shadow:
    0 0 14px rgba(32,153,177,0.32),
    inset 0 0 22px rgba(32,153,177,0.06);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.tile.tile-8 .tile-inner::before {
  background-image: url('../img/circuit-kb.svg');
  background-size: cover;
}
.tile.tile-8 .sf-main { font-size: 32px; color: #34b8d4; }

/* ══════════════════════════════════════════════════
   TIER 4 — MB (#00A859)
   Neon green power frame: bio-pulse, bleeding glow
   Icon: ▣ concentric square
   ══════════════════════════════════════════════════ */
@-webkit-keyframes bio-pulse {
  0%, 100% {
    box-shadow: 0 0 22px rgba(0,168,89,0.48), 0 0 44px rgba(0,168,89,0.14);
  }
  50% {
    box-shadow: 0 0 34px rgba(0,168,89,0.80), 0 0 68px rgba(0,168,89,0.28);
  }
}
@keyframes bio-pulse {
  0%, 100% {
    box-shadow: 0 0 22px rgba(0,168,89,0.48), 0 0 44px rgba(0,168,89,0.14);
  }
  50% {
    box-shadow: 0 0 34px rgba(0,168,89,0.80), 0 0 68px rgba(0,168,89,0.28);
  }
}

.tile.tile-16 .tile-inner {
  background: #051a0e;
  color: #00A859;
  border: 1px solid #00A859;
  -webkit-animation: bio-pulse 2.8s ease-in-out infinite;
  animation: bio-pulse 2.8s ease-in-out infinite;
}
.tile.tile-16 .tile-inner::before {
  background: radial-gradient(ellipse at 50% 40%, rgba(0,168,89,0.12) 0%, transparent 68%);
}
.tile.tile-16 .tile-inner::after {
  content: '';
  position: absolute;
  inset: 7px;
  border: 1.5px solid rgba(0,168,89,0.38);
  border-radius: 3px;
  z-index: 1;
  pointer-events: none;
}
.tile.tile-16 .sf-main { font-size: 30px; color: #00C46A; }

/* ══════════════════════════════════════════════════
   TIER 5 — GB (#3B5998)
   Frosted blue glass: multi-layer sapphire refraction
   Icon: ■ solid block
   ══════════════════════════════════════════════════ */
.tile.tile-32 .tile-inner {
  background: rgba(22, 38, 90, 0.75);
  color: #7a9ee0;
  border: 1px solid rgba(59,89,152,0.80);
  box-shadow:
    0 0 18px rgba(59,89,152,0.40),
    inset 0 0 28px rgba(59,89,152,0.08);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.tile.tile-32 .tile-inner::before {
  background: linear-gradient(
    140deg,
    rgba(255,255,255,0.12) 0%,
    transparent 36%,
    rgba(80,120,220,0.10) 60%,
    rgba(255,255,255,0.06) 80%,
    transparent 100%
  );
}
.tile.tile-32 .sf-main { font-size: 36px; color: #8fb0f0; }

/* ══════════════════════════════════════════════════
   TIER 6 — TB (#2E3192)
   Deep indigo cobalt: 3px chamfered border, beveled
   Icon: ⊟ inset square
   ══════════════════════════════════════════════════ */
.tile.tile-64 .tile-inner {
  background: #10122a;
  color: #6878c0;
  border: 3px solid #2E3192;
  box-shadow:
    0 0 0 1px rgba(46,49,146,0.40),
    inset 2px 2px 4px rgba(255,255,255,0.06),
    inset -2px -2px 4px rgba(0,0,0,0.40);
}
.tile.tile-64 .sf-main { font-size: 32px; color: #7888d0; }

/* ══════════════════════════════════════════════════
   TIER 7 — PB (#C1272D)
   Magenta energy field: turbulent plasma, flicker
   Icon: ₱ Peso sign
   ══════════════════════════════════════════════════ */
@-webkit-keyframes plasma-flicker {
  0%, 86%, 100% {
    box-shadow: 0 0 26px rgba(193,39,45,0.52);
    border-color: #C1272D;
  }
  88% {
    box-shadow: 0 0 55px rgba(193,39,45,0.96), inset 0 0 12px rgba(255,80,100,0.18);
    border-color: #ff5060;
  }
  91% {
    box-shadow: 0 0 14px rgba(193,39,45,0.28);
    border-color: #8a0c14;
  }
  93% {
    box-shadow: 0 0 48px rgba(193,39,45,0.85);
    border-color: #ff3848;
  }
  96% {
    box-shadow: 0 0 20px rgba(193,39,45,0.36);
    border-color: #a01020;
  }
}
@keyframes plasma-flicker {
  0%, 86%, 100% {
    box-shadow: 0 0 26px rgba(193,39,45,0.52);
    border-color: #C1272D;
  }
  88% {
    box-shadow: 0 0 55px rgba(193,39,45,0.96), inset 0 0 12px rgba(255,80,100,0.18);
    border-color: #ff5060;
  }
  91% {
    box-shadow: 0 0 14px rgba(193,39,45,0.28);
    border-color: #8a0c14;
  }
  93% {
    box-shadow: 0 0 48px rgba(193,39,45,0.85);
    border-color: #ff3848;
  }
  96% {
    box-shadow: 0 0 20px rgba(193,39,45,0.36);
    border-color: #a01020;
  }
}

.tile.tile-128 .tile-inner {
  background: #1e0308;
  color: #e83040;
  border: 1px solid #C1272D;
  -webkit-animation: plasma-flicker 4s ease-in-out infinite;
  animation: plasma-flicker 4s ease-in-out infinite;
}
.tile.tile-128 .tile-inner::before {
  background-image:
    radial-gradient(ellipse at 30% 60%, rgba(193,39,45,0.18) 0%, transparent 55%),
    radial-gradient(ellipse at 75% 30%, rgba(255,60,80,0.10) 0%, transparent 45%),
    url('../img/circuit-pb.svg');
  background-size: cover, cover, cover;
}
.tile.tile-128 .sf-main { font-size: 40px; color: #e83040; }

/* ══════════════════════════════════════════════════
   TIER 8 — EB (#D4A843)
   Crystallized Amber: faceted gemstone starburst,
   polished topaz slab, internal prismatic glow
   Icon: serif 'E' — embossed gold, 3D weighted
   ══════════════════════════════════════════════════ */
.tile.tile-256 .tile-inner {
  background:
    /* top-left champagne highlight facet */
    linear-gradient(135deg, rgba(255,240,160,0.28) 0%, transparent 38%),
    /* bottom-right deep chocolate shadow facet */
    linear-gradient(315deg, rgba(55,20,0,0.42) 0%, transparent 38%),
    /* amber base — deep chocolate to dark honey */
    linear-gradient(150deg, #221200 0%, #160900 40%, #1e1000 70%, #110700 100%);
  color: #D4A843;
  border: 2px solid rgba(212,168,67,0.75);
  box-shadow:
    /* outer amber glow */
    0 0 30px rgba(212,168,67,0.55),
    0 0 64px rgba(180,120,20,0.20),
    /* top/left bevel catch — champagne highlight */
    inset 0  1px 0 rgba(255,235,120,0.50),
    inset 1px 0  0 rgba(255,225,100,0.28),
    /* bottom/right bevel shadow — deep chocolate */
    inset 0 -1px 0 rgba(50,18,0,0.60),
    /* inner depth slab */
    inset 0  0  22px rgba(0,0,0,0.35);
}

/* Prismatic starburst facets + circuit trace overlay */
.tile.tile-256 .tile-inner::before {
  background-image:
    conic-gradient(from 0deg at 50% 50%,
      rgba(255,240,140,0.16)  0deg,
      rgba(120,55,5,0.20)    30deg,
      rgba(255,215,70,0.12)  60deg,
      rgba(80,30,0,0.22)     90deg,
      rgba(255,240,140,0.16) 120deg,
      rgba(120,55,5,0.20)   150deg,
      rgba(255,215,70,0.12) 180deg,
      rgba(80,30,0,0.22)    210deg,
      rgba(255,240,140,0.16) 240deg,
      rgba(120,55,5,0.20)   270deg,
      rgba(255,215,70,0.12) 300deg,
      rgba(80,30,0,0.22)    330deg,
      rgba(255,240,140,0.16) 360deg
    ),
    url('../img/circuit-eb.svg');
  background-size: cover, cover;
}

/* Beveled inner gem frame — polished topaz slab edge */
.tile.tile-256 .tile-inner::after {
  content: '';
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(212,168,67,0.22);
  border-radius: 3px;
  box-shadow:
    inset 0  1px 0 rgba(255,240,140,0.18),
    inset 0 -1px 0 rgba(40,15,0,0.42);
  z-index: 1;
  pointer-events: none;
}

/* Embossed serif 'E' — polished gold, 3D weighted */
.tile.tile-256 .sf-main {
  font-size: 52px;
  color: #e8c050;
  font-family: Georgia, 'Times New Roman', serif;
  font-weight: 700;
  /* light from top-left, shadow from bottom-right, inner glow */
  text-shadow:
    -1px -1px 0   rgba(255,240,160,0.85),
     1px  1px 2px rgba(40,15,0,0.80),
     0    0   8px rgba(212,168,67,0.55),
     0    0   18px rgba(180,120,20,0.28);
}

/* ══════════════════════════════════════════════════
   TIER 9 — ZB (beyond spec, purple)
   ══════════════════════════════════════════════════ */
.tile.tile-512 .tile-inner {
  background: #200840;
  color: #c060e0;
  border: 1px solid #8020a0;
  box-shadow: 0 0 36px rgba(128,32,160,0.6), inset 0 0 0 1px rgba(255,255,255,0.06);
}
.tile.tile-512 .tile-inner::before {
  background-image: url('../img/circuit-zb.svg');
  background-size: cover;
}

/* ══════════════════════════════════════════════════
   TIER 10 — YB (beyond spec, deep orange)
   ══════════════════════════════════════════════════ */
.tile.tile-1024 .tile-inner {
  background: #200a02;
  color: #f07040;
  border: 1px solid #d04010;
  box-shadow: 0 0 42px rgba(208,64,16,0.65), inset 0 0 0 1px rgba(255,255,255,0.06);
}
.tile.tile-1024 .tile-inner::before {
  background-image: url('../img/circuit-yb.svg');
  background-size: cover;
}

/* ══════════════════════════════════════════════════
   TIER 11 — FORGE (win state, cyan IC)
   ══════════════════════════════════════════════════ */
@-webkit-keyframes forge-pulse {
  0%, 100% { box-shadow: 0 0 55px rgba(0,232,255,0.85), inset 0 0 20px rgba(0,232,255,0.08); }
  50%       { box-shadow: 0 0 80px rgba(0,232,255,1.00), inset 0 0 35px rgba(0,232,255,0.18); }
}
@keyframes forge-pulse {
  0%, 100% { box-shadow: 0 0 55px rgba(0,232,255,0.85), inset 0 0 20px rgba(0,232,255,0.08); }
  50%       { box-shadow: 0 0 80px rgba(0,232,255,1.00), inset 0 0 35px rgba(0,232,255,0.18); }
}

.tile.tile-2048 .tile-inner {
  background: #001018;
  color: #00e8ff;
  border: 1px solid #00e8ff;
  -webkit-animation: forge-pulse 1.6s ease-in-out infinite;
  animation: forge-pulse 1.6s ease-in-out infinite;
}
.tile.tile-2048 .tile-inner::before {
  background-image: url('../img/circuit-forge.svg');
  background-size: cover;
}
.tile.tile-2048 .sf-main { font-size: 16px; letter-spacing: 0.08em; color: #00e8ff; }

/* QUBIT — beyond FORGE */
.tile.tile-super .tile-inner {
  background: #140020;
  color: #ff70b0;
  border: 1px solid #ff5090;
  box-shadow: 0 0 60px rgba(255,80,144,0.75), inset 0 0 20px rgba(255,80,144,0.08);
}

/* ── Tile animations ──────────────────────────────── */
@-webkit-keyframes appear {
  0%   { opacity: 0; -webkit-transform: scale(0); transform: scale(0); }
  100% { opacity: 1; -webkit-transform: scale(1); transform: scale(1); }
}
@keyframes appear {
  0%   { opacity: 0; transform: scale(0); }
  100% { opacity: 1; transform: scale(1); }
}
.tile-new .tile-inner {
  -webkit-animation: appear 200ms ease 100ms;
  animation: appear 200ms ease 100ms;
  -webkit-animation-fill-mode: backwards;
  animation-fill-mode: backwards;
}

@-webkit-keyframes pop {
  0%   { -webkit-transform: scale(0);    transform: scale(0);    }
  50%  { -webkit-transform: scale(1.22); transform: scale(1.22); }
  100% { -webkit-transform: scale(1);    transform: scale(1);    }
}
@keyframes pop {
  0%   { transform: scale(0);    }
  50%  { transform: scale(1.22); }
  100% { transform: scale(1);    }
}
.tile-merged .tile-inner {
  z-index: 20;
  -webkit-animation: pop 200ms ease 100ms;
  animation: pop 200ms ease 100ms;
  -webkit-animation-fill-mode: backwards;
  animation-fill-mode: backwards;
}

/* ── Above-game bar ───────────────────────────────── */
.above-game:after { content: ""; display: block; clear: both; }

.game-intro {
  float: left;
  line-height: 40px;
  margin-bottom: 0;
  font-size: 12px;
  color: #38404e;
  letter-spacing: 0.02em;
}
.game-intro strong { color: #2099B1; }

/* Mechanical key button */
.restart-button {
  display: block;
  float: right;
  background: #0d1018;
  border: 1px solid #2a3040;
  border-bottom: 3px solid #161c28;
  border-radius: 4px;
  padding: 0 18px;
  text-decoration: none;
  color: #2099B1;
  height: 38px;
  line-height: 38px;
  text-align: center;
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  -webkit-transition: border-color 0.1s, background 0.1s, -webkit-transform 0.05s;
  transition: border-color 0.1s, background 0.1s, transform 0.05s;
}
.restart-button:hover { border-color: #00e8ff; background: rgba(0,232,255,0.05); }
.restart-button:active { -webkit-transform: translateY(2px); transform: translateY(2px); border-bottom-width: 1px; }

/* ── Game explanation ─────────────────────────────── */
.game-explanation { margin-top: 32px; font-size: 12px; color: #2a3040; line-height: 1.8; }

/* ── Stack panel (sidebar) ────────────────────────── */
.stack-panel {
  width: 140px;
  -webkit-flex-shrink: 0;
  flex-shrink: 0;
  padding: 14px 10px;
  background: #0f1219;
  border: 1px solid #1e2330;
  border-radius: 8px;
  font-family: inherit;
  box-shadow: 0 0 40px rgba(0,0,0,0.5);
}

.stack-title {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: #2a3040;
  margin: 0 0 10px;
  text-align: left;
  text-transform: uppercase;
}

.stack-items {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  gap: 4px;
  min-height: 48px;
}

.stack-item {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  padding: 5px 8px;
  border-radius: 4px;
  border: 1px solid #1a2030;
  background: #0c0e14;
  font-family: inherit;
}

.stack-tier-label { font-size: 11px; font-weight: 700; letter-spacing: 0.04em; color: #4a5570; }
.stack-tier-val   { font-size: 9px; color: #2a3040; }

/* Tier-colored stack items */
.stack-item[data-v="2"]    .stack-tier-label { color: #4a5058; }
.stack-item[data-v="4"]    .stack-tier-label { color: #7090a8; }
.stack-item[data-v="8"]    { border-color: #062030; } .stack-item[data-v="8"]    .stack-tier-label { color: #2099B1; }
.stack-item[data-v="16"]   { border-color: #041a0a; } .stack-item[data-v="16"]   .stack-tier-label { color: #00A859; }
.stack-item[data-v="32"]   { border-color: #101c40; } .stack-item[data-v="32"]   .stack-tier-label { color: #7a9ee0; }
.stack-item[data-v="64"]   { border-color: #101248; } .stack-item[data-v="64"]   .stack-tier-label { color: #6878c0; }
.stack-item[data-v="128"]  { border-color: #2a0408; } .stack-item[data-v="128"]  .stack-tier-label { color: #C1272D; }
.stack-item[data-v="256"]  { border-color: #2a1800; } .stack-item[data-v="256"]  .stack-tier-label { color: #D4A843; }
.stack-item[data-v="512"]  { border-color: #3a0c60; } .stack-item[data-v="512"]  .stack-tier-label { color: #c060e0; }
.stack-item[data-v="1024"] { border-color: #3a1008; } .stack-item[data-v="1024"] .stack-tier-label { color: #f07040; }
.stack-item[data-v="2048"] { border-color: #003040; } .stack-item[data-v="2048"] .stack-tier-label { color: #00e8ff; }

.stack-empty { font-size: 9px; color: #1e2530; text-align: center; padding: 8px 0; letter-spacing: 0.06em; }

.stack-sep { height: 1px; background: #1e2330; margin: 12px 0; }

/* Next target */
.stack-target-wrap { margin-top: 6px; }

.target-tile {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  gap: 3px;
  height: 58px;
  border-radius: 5px;
  border: 1px solid #1e2330;
  background: #0c0e14;
  font-family: inherit;
  text-align: center;
}

.target-main { font-size: 22px; font-weight: 700; line-height: 1; color: #2a3040; }
.target-sub  { font-size: 9px; color: #1e2530; letter-spacing: 0.06em; text-transform: uppercase; }

.target-tile[data-v="4"]    { border-color: #3a4858; }  .target-tile[data-v="4"]    .target-main { color: #7090a8; }
.target-tile[data-v="8"]    { border-color: #062030; }  .target-tile[data-v="8"]    .target-main { color: #2099B1; }
.target-tile[data-v="16"]   { border-color: #041a0a; }  .target-tile[data-v="16"]   .target-main { color: #00A859; }
.target-tile[data-v="32"]   { border-color: #101c40; }  .target-tile[data-v="32"]   .target-main { color: #7a9ee0; }
.target-tile[data-v="64"]   { border-color: #101248; }  .target-tile[data-v="64"]   .target-main { color: #6878c0; }
.target-tile[data-v="128"]  { border-color: #2a0408; }  .target-tile[data-v="128"]  .target-main { color: #C1272D; }
.target-tile[data-v="256"]  { border-color: #2a1800; }  .target-tile[data-v="256"]  .target-main { color: #D4A843; }
.target-tile[data-v="512"]  { border-color: #3a0c60; }  .target-tile[data-v="512"]  .target-main { color: #c060e0; }
.target-tile[data-v="1024"] { border-color: #3a1008; }  .target-tile[data-v="1024"] .target-main { color: #f07040; }
.target-tile[data-v="2048"] { border-color: #003040; box-shadow: 0 0 12px rgba(0,232,255,0.28); }
.target-tile[data-v="2048"] .target-main { color: #00e8ff; }
.target-tile[data-v="max"]  .target-main { font-size: 14px; color: #00e8ff; letter-spacing: 0.1em; }

/* ── Responsive ───────────────────────────────────── */
@media screen and (max-width: 700px) {
  .forge-wrapper { -webkit-flex-direction: column; flex-direction: column; -webkit-align-items: center; align-items: center; }
  .stack-panel { width: 500px; box-sizing: border-box; padding: 12px 14px; }
  .stack-title { margin-bottom: 8px; }
  .stack-items { -webkit-flex-direction: row; flex-direction: row; -webkit-flex-wrap: wrap; flex-wrap: wrap; gap: 4px; min-height: unset; }
  .stack-item { -webkit-flex: 0 0 calc(25% - 3px); flex: 0 0 calc(25% - 3px); -webkit-justify-content: center; justify-content: center; -webkit-flex-direction: column; flex-direction: column; gap: 2px; padding: 5px 4px; text-align: center; }
  .stack-sep { margin: 8px 0; }
  .stack-target-wrap { display: -webkit-flex; display: flex; gap: 8px; -webkit-align-items: center; align-items: center; }
  .target-tile { -webkit-flex: 1; flex: 1; height: 44px; }
}

@media screen and (max-width: 520px) {
  html, body { font-size: 15px; }
  body { margin: 20px 0; padding: 0 16px; }
  h1.title { font-size: 22px; margin-top: 10px; }
  .container { width: 280px; margin: 0 auto; }
  .score-container, .best-container { margin-top: 0; padding: 18px 8px 5px; min-width: 50px; font-size: 16px; margin-left: 5px; }
  .heading { margin-bottom: 10px; }
  .game-intro { width: 55%; display: block; box-sizing: border-box; line-height: 1.65; }
  .restart-button { width: 42%; padding: 0; display: block; box-sizing: border-box; margin-top: 2px; }
  .game-container { margin-top: 14px; padding: 10px; width: 280px; height: 280px; box-sizing: border-box; }
  .game-container .game-message p { font-size: 24px !important; height: 30px !important; line-height: 30px !important; margin-top: 110px !important; }
  .game-container .game-message .lower { margin-top: 28px !important; }
  .grid-container { position: absolute; z-index: 1; }
  .grid-row { margin-bottom: 10px; }
  .grid-row:last-child { margin-bottom: 0; }
  .grid-row:after { content: ""; display: block; clear: both; }
  .grid-cell { width: 57.5px; height: 57.5px; margin-right: 10px; float: left; border-radius: 3px; background: rgba(255,255,255,0.022); border: 1px solid rgba(255,255,255,0.033); }
  .grid-cell:last-child { margin-right: 0; }
  .tile-container { position: absolute; z-index: 2; }
  .tile, .tile .tile-inner { width: 58px; height: 58px; }
  .tile .sf-main { font-size: 18px !important; }
  .tile .sf-sub  { font-size: 7px; }
  .tile.tile-4 .sf-byte-dots { grid-template-columns: repeat(3, 6px); grid-template-rows: repeat(3, 6px); gap: 3px; }
  .tile.tile-4 .sf-byte-dots span { width: 6px; height: 6px; }
  .tile.tile-256 .sf-main { font-family: Georgia, 'Times New Roman', serif !important; }
  .tile.tile-2048 .sf-main { font-size: 11px !important; }
  .tile.tile-position-1-1 { -webkit-transform: translate(0px,   0px);   transform: translate(0px,   0px);   }
  .tile.tile-position-1-2 { -webkit-transform: translate(0px,   67px);  transform: translate(0px,   67px);  }
  .tile.tile-position-1-3 { -webkit-transform: translate(0px,   135px); transform: translate(0px,   135px); }
  .tile.tile-position-1-4 { -webkit-transform: translate(0px,   202px); transform: translate(0px,   202px); }
  .tile.tile-position-2-1 { -webkit-transform: translate(67px,  0px);   transform: translate(67px,  0px);   }
  .tile.tile-position-2-2 { -webkit-transform: translate(67px,  67px);  transform: translate(67px,  67px);  }
  .tile.tile-position-2-3 { -webkit-transform: translate(67px,  135px); transform: translate(67px,  135px); }
  .tile.tile-position-2-4 { -webkit-transform: translate(67px,  202px); transform: translate(67px,  202px); }
  .tile.tile-position-3-1 { -webkit-transform: translate(135px, 0px);   transform: translate(135px, 0px);   }
  .tile.tile-position-3-2 { -webkit-transform: translate(135px, 67px);  transform: translate(135px, 67px);  }
  .tile.tile-position-3-3 { -webkit-transform: translate(135px, 135px); transform: translate(135px, 135px); }
  .tile.tile-position-3-4 { -webkit-transform: translate(135px, 202px); transform: translate(135px, 202px); }
  .tile.tile-position-4-1 { -webkit-transform: translate(202px, 0px);   transform: translate(202px, 0px);   }
  .tile.tile-position-4-2 { -webkit-transform: translate(202px, 67px);  transform: translate(202px, 67px);  }
  .tile.tile-position-4-3 { -webkit-transform: translate(202px, 135px); transform: translate(202px, 135px); }
  .tile.tile-position-4-4 { -webkit-transform: translate(202px, 202px); transform: translate(202px, 202px); }
  .stack-panel { width: 280px; }
  .stack-item { -webkit-flex: 0 0 calc(25% - 3px); flex: 0 0 calc(25% - 3px); }
}
