:root {
  --ink-deep: #0d0a2b;
  --ink-panel: #161244;
  --line: #3d2f7a;
  --paper: #eeeafc;
  --mint: #7c9dfc;
  --amber: #b389f9;
  --coral: #ef6e64;
  --text-dim: #9a8fc9;
  --wordle-correct: #5fb968;
  --wordle-present: #e2c14c;
  --ripple-pink: #ff5fae;
  --ripple-blue: #5f8bff;
  --ripple-violet: #a24bef;
  --font-display: 'Space Grotesk', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
  --grid-x: 50%;
  --grid-y: 40%;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  background: var(--ink-deep);
  color: var(--paper);
  font-family: var(--font-mono);
  position: relative;
  overflow-x: hidden;
}

.ripple-layer {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  background: var(--ink-deep);
}

.grid-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 42px 42px;
  background-position: var(--grid-x) var(--grid-y);
  opacity: 0.28;
  mask-image: radial-gradient(220px circle at var(--grid-x) var(--grid-y), black 0%, rgba(0,0,0,0.5) 55%, transparent 100%);
  -webkit-mask-image: radial-gradient(220px circle at var(--grid-x) var(--grid-y), black 0%, rgba(0,0,0,0.5) 55%, transparent 100%);
  transition: background-position 0.6s cubic-bezier(0.16, 1, 0.3, 1), mask-position 0.6s ease;
}

.mouse-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(
    260px circle at var(--grid-x) var(--grid-y),
    rgba(255, 111, 176, 0.24) 0%,
    rgba(150, 145, 250, 0.14) 25%,
    rgba(95, 201, 255, 0.10) 50%,
    rgba(95, 201, 255, 0.03) 75%,
    transparent 100%
  );
  transition: background-position 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  filter: blur(8px);
}

.page {
  width: 100%;
  max-width: 620px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: relative;
  z-index: 1;
}

.console {
  width: 100%;
  background: var(--ink-panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  position: relative;
}

.console__bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: #0e2129;
  border-bottom: 1px solid var(--line);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.console__bar.is-dragging {
  cursor: grabbing;
}

.console.is-floating {
  position: fixed;
  margin: 0;
  box-shadow: 0 40px 90px -20px rgba(0, 0, 0, 0.75);
  resize: none;
  overflow: auto;
  min-width: 300px;
  min-height: 220px;
  max-width: 92vw;
  max-height: 90vh;
  scrollbar-width: thin;
  scrollbar-color: var(--line) var(--ink-panel);
}

.console.is-floating::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.console.is-floating::-webkit-scrollbar-track {
  background: var(--ink-panel);
}

.console.is-floating::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 6px;
  border: 2px solid var(--ink-panel);
}

.console.is-floating::-webkit-scrollbar-thumb:hover {
  background: var(--mint);
}

.console.is-floating::-webkit-scrollbar-corner {
  background: var(--ink-panel);
}

.console.is-floating .console__bar {
  border-bottom-color: var(--mint);
}

.resize-handle {
  position: absolute;
  z-index: 4;
  touch-action: none;
}

.console:not(.is-floating) .resize-handle {
  display: none;
}

.resize-handle--n,
.resize-handle--s {
  left: 10px;
  right: 10px;
  height: 8px;
  cursor: ns-resize;
}
.resize-handle--n { top: 0; }
.resize-handle--s { bottom: 0; }

.resize-handle--e,
.resize-handle--w {
  top: 10px;
  bottom: 10px;
  width: 8px;
  cursor: ew-resize;
}
.resize-handle--e { right: 0; }
.resize-handle--w { left: 0; }

.resize-handle--ne,
.resize-handle--nw,
.resize-handle--se,
.resize-handle--sw {
  width: 14px;
  height: 14px;
}
.resize-handle--ne { top: 0; right: 0; cursor: nesw-resize; }
.resize-handle--nw { top: 0; left: 0; cursor: nwse-resize; }
.resize-handle--se { bottom: 0; right: 0; cursor: nwse-resize; }
.resize-handle--sw { bottom: 0; left: 0; cursor: nesw-resize; }

/* ---- Side taskbar: a persistent tab (cap + arrow + long tail) docked to the edge ---- */

.side-nav {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  z-index: 60;
  display: flex;
  align-items: stretch;
  padding-top: 22vh;
  pointer-events: none;
}

.side-nav--right {
  left: auto;
  right: 0;
  align-items: center;
  padding-top: 0;
}

.side-nav__trigger {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 84px;
  pointer-events: auto;
}

.side-nav--right .side-nav__trigger {
  left: auto;
  right: 0;
}

@media (hover: none) {
  .side-nav__trigger {
    pointer-events: none;
  }
}

.taskbar {
  position: relative;
  display: flex;
  align-items: stretch;
  pointer-events: auto;
}

.taskbar__handle {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 40px;
  padding: 0;
  color: var(--text-dim);
  background: var(--ink-panel);
  border: 1px solid var(--line);
  border-right: none;
  border-radius: 10px 0 0 10px;
  cursor: pointer;
  position: relative;
  z-index: 2;
  transition: color 0.15s ease;
}

.taskbar__handle:hover {
  color: var(--mint);
}

.taskbar__arrow {
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.side-nav:hover .taskbar__arrow,
.taskbar.is-open .taskbar__arrow {
  transform: rotate(180deg);
}

.taskbar__panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 0;
  padding: 18px 0;
  overflow: hidden;
  white-space: nowrap;
  background: var(--ink-panel);
  border: 1px solid var(--line);
  border-left: none;
  border-radius: 0 10px 10px 0;
  box-shadow: 24px 0 60px -24px rgba(0, 0, 0, 0.7);
  transition:
    width 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    padding 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.side-nav:hover .taskbar__panel,
.taskbar.is-open .taskbar__panel {
  width: 160px;
  padding: 18px;
}

/* Home page taskbar (right-docked): the handle floats to the left of the
   panel rather than sitting flush against the true screen edge. It shares
   the same rounded-left/flat-right shape as the arrow tab on other pages;
   only its size is overridden here. */
.taskbar__cluster {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.taskbar__cluster .taskbar__handle {
  width: 56px;
  height: 76px;
}

.taskbar__cluster .taskbar__arrow {
  width: 20px;
  height: 20px;
}

.taskbar__link {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--paper);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 15px 14px;
  text-decoration: none;
  text-align: center;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.taskbar__link:hover {
  color: var(--ink-deep);
  background: var(--mint);
  border-color: var(--mint);
}

.games-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 22px;
}

.games-list__item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.games-list__item:hover {
  border-color: var(--mint);
  background: rgba(124, 157, 252, 0.06);
  transform: translateX(2px);
}

.games-list__name {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--mint);
}

.games-list__desc {
  font-size: 12px;
  color: var(--text-dim);
}

/* ---- Shared game HUD / overlay / hint (snake, wordle, future games) ---- */

.game-hud {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-dim);
  text-transform: lowercase;
}

.game-stat strong {
  color: var(--mint);
  font-weight: 600;
  margin-left: 4px;
}

.game-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  text-align: center;
  background: rgba(13, 10, 43, 0.82);
  cursor: pointer;
  transition: opacity 0.2s ease;
  z-index: 5;
}

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

.game-overlay__title {
  font-family: var(--font-display);
  font-size: clamp(22px, 5vw, 28px);
  margin: 0;
  color: var(--mint);
  text-transform: lowercase;
  min-height: 1em;
}

.game-overlay__sub {
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
  max-width: 260px;
}

.game-hint {
  margin: 0;
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
}

.snake {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 22px;
}

.snake__stage {
  position: relative;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #0e2129;
  touch-action: none;
}

#snakeCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.wordle {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 22px;
}

.wordle__stage {
  position: relative;
}

.wordle__board {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
}

.wordle__row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  perspective: 400px;
}

.wordle__row--shake {
  animation: wordle-shake 0.4s ease;
}

@keyframes wordle-shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}

.wordle__tile {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: clamp(18px, 4.5vw, 24px);
  font-weight: 700;
  color: var(--paper);
  background: #0e2129;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-transform: uppercase;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.wordle__tile--filled {
  border-color: var(--text-dim);
}

.wordle__tile--flip {
  transform: rotateX(90deg);
}

.wordle__tile--correct {
  background: var(--wordle-correct);
  border-color: var(--wordle-correct);
  color: var(--ink-deep);
}

.wordle__tile--present {
  background: var(--wordle-present);
  border-color: var(--wordle-present);
  color: var(--ink-deep);
}

.wordle__tile--absent {
  background: rgba(61, 47, 122, 0.5);
  border-color: var(--line);
  color: var(--text-dim);
}

.wordle__message {
  margin: 0;
  min-height: 1em;
  font-size: 12px;
  color: var(--coral);
  text-align: center;
}

.wordle__keyboard {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wordle__krow {
  display: flex;
  justify-content: center;
  gap: 5px;
}

.wordle__key {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--paper);
  background: rgba(61, 47, 122, 0.5);
  border: none;
  border-radius: 5px;
  padding: 12px 0;
  flex: 1;
  min-width: 0;
  max-width: 38px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.wordle__key:hover {
  background: var(--line);
}

.wordle__key:active {
  transform: scale(0.94);
}

.wordle__key--wide {
  max-width: 56px;
  font-size: 10px;
  text-transform: lowercase;
}

.wordle__key--correct {
  background: var(--wordle-correct);
  color: var(--ink-deep);
}

.wordle__key--present {
  background: var(--wordle-present);
  color: var(--ink-deep);
}

.wordle__key--absent {
  background: rgba(61, 47, 122, 0.25);
  color: var(--text-dim);
}

@media (max-width: 420px) {
  .wordle__key {
    padding: 10px 0;
    max-width: 32px;
  }
  .wordle__key--wide {
    max-width: 46px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .wordle__tile,
  .wordle__row--shake {
    animation: none;
    transition: none;
  }
}

.tunnel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 22px;
}

.tunnel__stage {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  aspect-ratio: 480 / 260;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #0e2129;
}

#tunnelCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.tunnel__controls {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.tunnel__btn {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  color: var(--paper);
  background: rgba(61, 47, 122, 0.5);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 22px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}

.tunnel__btn:hover {
  color: var(--ink-deep);
  background: var(--mint);
  border-color: var(--mint);
}

.tunnel__btn:active {
  transform: scale(0.96);
}

body.is-interacting {
  user-select: none;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  opacity: 0.85;
}
.dot--red { background: var(--coral); }
.dot--amber { background: var(--amber); }
.dot--green { background: var(--mint); }

.console__title {
  margin-left: 8px;
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

.console__body {
  padding: 28px 28px 8px;
}

.console__body:last-child {
  padding-bottom: 28px;
}

.console__line {
  margin: 0 0 18px;
  font-size: 13px;
}
.console__line--muted {
  color: var(--text-dim);
}

.checklist {
  list-style: none;
  margin: 0 0 24px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.checklist__item {
  font-size: 13px;
  color: var(--text-dim);
  position: relative;
  padding-left: 26px;
  opacity: 0.45;
  transition: opacity 0.3s ease, color 0.3s ease;
}

.checklist__item::before {
  content: "○";
  position: absolute;
  left: 0;
  color: var(--text-dim);
}

.checklist__item.is-done {
  opacity: 1;
  color: var(--paper);
}

.checklist__item.is-done::before {
  content: "✓";
  color: var(--mint);
}

.result {
  border-top: 1px dashed var(--line);
  border-bottom: 1px dashed var(--line);
  padding: 22px 0;
  margin-bottom: 22px;
}

.result__headline {
  font-family: var(--font-display);
  font-size: clamp(28px, 6vw, 40px);
  margin: 0 0 6px;
  color: var(--text-dim);
  letter-spacing: -0.01em;
  transition: color 0.4s ease;
  text-transform: lowercase;
}

.result__headline.is-live {
  color: var(--mint);
}

.result__sub {
  margin: 0;
  font-size: 13px;
  color: var(--text-dim);
}

.meta {
  margin: 0 0 26px;
  display: grid;
  grid-template-columns: auto 1fr;
  row-gap: 8px;
  column-gap: 18px;
  font-size: 12px;
}

.meta__row {
  display: contents;
}

.meta dt {
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 10px;
  align-self: center;
}

.meta dd {
  margin: 0;
  color: var(--paper);
  word-break: break-word;
}

.rerun {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-deep);
  background: var(--mint);
  border: none;
  border-radius: 6px;
  padding: 10px 16px;
  margin-bottom: 24px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.rerun:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px -8px rgba(127, 231, 196, 0.6);
}

.rerun:focus-visible,
.rerun:focus {
  outline: 2px solid var(--paper);
  outline-offset: 2px;
}

.console__footer {
  padding: 14px 28px 20px;
  font-size: 11px;
  color: var(--text-dim);
  border-top: 1px solid var(--line);
}

.converter {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 22px;
}

.converter__tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.converter__tab,
.converter__format-btn {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.converter__tab:hover,
.converter__format-btn:hover {
  color: var(--paper);
  border-color: var(--mint);
}

.converter__tab.is-active,
.converter__format-btn.is-active {
  color: var(--ink-deep);
  background: var(--mint);
  border-color: var(--mint);
}

.converter__tabs--format {
  margin-top: -4px;
}

.converter__format-btn {
  font-size: 10px;
  padding: 5px 10px;
  opacity: 0.85;
}

.converter__format-btn.is-active {
  opacity: 1;
}

.converter__row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.converter__field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.converter__input {
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--paper);
  background: #0e2129;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  width: 100%;
  min-width: 0;
}

.converter__input:focus,
.converter__input:focus-visible {
  outline: none;
  border-color: var(--mint);
}

.converter__input[readonly] {
  color: var(--mint);
}

.converter__select {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--paper);
  background: #0e2129;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  width: 100%;
}

.converter__swap {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  margin-top: 22px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-dim);
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.2s ease, color 0.15s ease, border-color 0.15s ease;
}

.converter__swap:hover {
  color: var(--mint);
  border-color: var(--mint);
  transform: rotate(180deg);
}

.converter__note {
  margin: 0;
  font-size: 11px;
  color: var(--text-dim);
}

@media (max-width: 420px) {
  .converter__row {
    flex-direction: column;
    align-items: stretch;
  }
  .converter__swap {
    align-self: center;
    margin-top: 0;
    transform: rotate(90deg);
  }
  .converter__swap:hover {
    transform: rotate(270deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .checklist__item,
  .result__headline,
  .rerun,
  .taskbar,
  .taskbar__arrow,
  .taskbar__panel {
    transition: none;
    animation: none;
  }
}

@media (max-width: 420px) {
  .console__body {
    padding: 22px 18px 6px;
  }
  .console__footer {
    padding: 12px 18px 18px;
  }
}
