@font-face {
  font-family: 'NokiaPixel';
  src: local('Courier New');
}

:root {
  --shell-dark: #2b2d26;
  --shell-mid: #46493d;
  --lcd-bg: #9aad55;
  --lcd-bg-dark: #8a9c48;
  --lcd-ink: #26311a;
  --key-shadow: rgba(0, 0, 0, 0.55);
  --accent: #cfd8b0;
  --well-bg: #14161c;
  --well-bg-dark: #0c0d11;
  font-size: 16px;
}

* { box-sizing: border-box; }

.hidden { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #111;
  font-family: 'NokiaPixel', 'Courier New', Courier, monospace;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: none;
}

.phone {
  position: relative;
  overflow: hidden;
  height: 100dvh;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: linear-gradient(160deg, var(--shell-mid), var(--shell-dark) 70%);
  border-left: 1px solid #55584a;
  border-right: 1px solid #1a1b16;
}

/* ===================== 70% SCREEN ===================== */

.screen-area {
  flex: 7 1 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(8px, 3vh, 20px) clamp(10px, 4vw, 24px) clamp(4px, 1.5vh, 10px);
}

/* The well itself is dark so the classic bright piece colors actually pop —
   the rest of the shell stays on-brand with the other games' green LCD. */
.lcd {
  position: relative;
  width: 100%;
  height: 100%;
  background: linear-gradient(160deg, var(--well-bg), var(--well-bg-dark) 80%);
  border-radius: 10px;
  border: 3px solid #1c1d17;
  box-shadow:
    inset 0 0 0 2px #33363f,
    inset 0 2px 14px rgba(0, 0, 0, 0.6),
    0 1px 0 rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.status-bar {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px 4px;
  font-size: 0.68rem;
  letter-spacing: 0.5px;
  color: var(--accent);
  font-weight: bold;
  border-bottom: 1px solid rgba(207, 216, 176, 0.15);
}

.next-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.next-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: #666;
  font-style: normal;
}

.screen-inner {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  padding: 2px 6px 8px;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(154, 173, 85, 0.96);
  text-align: center;
  padding: 10px;
}

.overlay.hidden { display: none; }
.overlay-content.hidden { display: none; }

.overlay-content {
  color: var(--lcd-ink);
  width: 100%;
}

.logo {
  margin: 0 0 4px;
  font-size: clamp(1.4rem, 6vw, 2.1rem);
  letter-spacing: 4px;
}

.subtitle {
  margin: 0 0 8px;
  font-size: 0.75rem;
  letter-spacing: 1px;
}

.hi-line {
  margin: 0 0 14px;
  font-size: 0.68rem;
  letter-spacing: 0.5px;
  opacity: 0.85;
}

.hint {
  font-size: 0.72rem;
  letter-spacing: 0.5px;
  margin: 4px 0 0;
}

.blink { animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ===================== 30% CONTROLS ===================== */

.controls-area {
  flex: 3 1 0;
  min-height: 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px clamp(16px, 6vw, 34px) max(10px, env(safe-area-inset-bottom));
}

/* Same technique as the Snake site's split-button row: container query
   units size each button from the row's own realized box (both width and
   height), so 4-across stays square without the flex-basis/aspect-ratio
   conflicts that come from mixing flex-grow with a pinned cross size. */
.controls3 {
  container-type: size;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: min(100%, 300px);
  width: 100%;
}

.cbtn {
  flex: 0 0 auto;
  min-width: 0;
  min-height: 0;
  width: min(20cqw, 96cqh);
  height: min(20cqw, 96cqh);
  font-family: inherit;
  font-size: clamp(1.4rem, 6.5vh, 2.4rem);
  color: var(--accent);
  background: linear-gradient(160deg, #5b5f4d, #34362b 85%);
  border: 1px solid #1c1d17;
  border-radius: 14px;
  box-shadow:
    0 4px 0 var(--key-shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.05s ease;
}

.cbtn:active,
.cbtn.pressed {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--key-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  background: linear-gradient(160deg, #6d715c, #3f4234 85%);
}

.cbtn.rotate {
  border-radius: 50%;
  font-size: clamp(1.3rem, 7vh, 2.2rem);
  background: linear-gradient(160deg, #7a5f3d, #45341f 85%);
}

.cbtn.rotate:active,
.cbtn.rotate.pressed {
  background: linear-gradient(160deg, #8c7048, #55402a 85%);
}

/* ===================== Dock ===================== */

.dock-handle {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  width: 26px;
  height: 68px;
  border: 1px solid #1c1d17;
  border-right: none;
  border-radius: 10px 0 0 10px;
  background: linear-gradient(160deg, #5b5f4d, #34362b 85%);
  color: var(--accent);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 20;
  box-shadow: -2px 0 6px rgba(0, 0, 0, 0.35);
}

.dock {
  position: absolute;
  top: 50%;
  right: 26px;
  transform: translate(calc(100% + 40px), -50%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: linear-gradient(160deg, var(--shell-mid), var(--shell-dark) 85%);
  border: 1px solid #1c1d17;
  border-right: none;
  border-radius: 10px 0 0 10px;
  z-index: 15;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.4);
}

.dock.open { transform: translate(0, -50%); }

.side-btn {
  min-width: 92px;
  font-family: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.5px;
  color: var(--accent);
  background: linear-gradient(160deg, #5b5f4d, #34362b 85%);
  border: 1px solid #1c1d17;
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: 0 3px 0 var(--key-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  text-align: center;
  display: block;
}

.side-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--key-shadow);
}

@media (min-width: 480px) and (min-height: 700px) {
  :root { font-size: 18px; }
}
