/* ── Themes via custom properties ── */
:root,
[data-theme="classic"] {
  --text-color: #fff;
  --text-glow: none;
  --tile-top: #2a2a2a;
  --tile-bottom: #222;
  --tile-border: #111;
}
[data-theme="retro-green"] {
  --text-color: #39ff14;
  --text-glow: 0 0 8px #39ff1480;
  --tile-top: #1a2e1a;
  --tile-bottom: #152015;
  --tile-border: #0a150a;
}
[data-theme="neon-pink"] {
  --text-color: #ff2d95;
  --text-glow: 0 0 8px #ff2d9580;
  --tile-top: #2e1a28;
  --tile-bottom: #201520;
  --tile-border: #150a12;
}
[data-theme="sunset"] {
  --text-color: #ff6a00;
  --text-glow: 0 0 8px #ff6a0080;
  --tile-top: #2e2218;
  --tile-bottom: #201a12;
  --tile-border: #15100a;
}
[data-theme="ocean"] {
  --text-color: #00b4d8;
  --text-glow: 0 0 8px #00b4d880;
  --tile-top: #182a2e;
  --tile-bottom: #122025;
  --tile-border: #0a151a;
}
[data-theme="terminal"] {
  --text-color: #ffb000;
  --text-glow: 0 0 8px #ffb00080;
  --tile-top: #2e2a18;
  --tile-bottom: #202012;
  --tile-border: #15140a;
}

/* ── Neon cycling colors for scramble phase ── */
@keyframes neonCycle {
  0%   { color: #ff2d95; }
  25%  { color: #39ff14; }
  50%  { color: #00b4d8; }
  75%  { color: #ffb000; }
  100% { color: #ff2d95; }
}

/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: #111;
  color: #ccc;
  font-family: 'Courier New', Courier, monospace;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 2rem 1rem;
}

.container {
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.logo {
  font-size: 1.5rem;
  letter-spacing: 0.4em;
  color: #666;
  font-weight: 400;
}

.hidden { display: none !important; }

/* ── Board ── */
.board {
  display: grid;
  gap: 4px;
  justify-content: center;
  perspective: 600px;
  width: 100%;
}

/* ── Tile ── */
.tile {
  width: clamp(28px, 4vw, 48px);
  height: clamp(38px, 5.5vw, 64px);
  position: relative;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
}

.tile-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform 0.3s ease-in-out;
}

.tile.flipping .tile-inner {
  transform: rotateX(-180deg);
}

.tile-face {
  position: absolute;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Courier New', Courier, monospace;
  font-size: clamp(16px, 2.5vw, 32px);
  font-weight: 700;
  border-radius: 4px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  color: var(--text-color);
  text-shadow: var(--text-glow);
}

.tile-front {
  background: linear-gradient(180deg, var(--tile-top) 49%, var(--tile-border) 49%, var(--tile-border) 51%, var(--tile-bottom) 51%);
  box-shadow: 0 2px 4px #0005, inset 0 1px 0 #fff1;
}

.tile-back {
  background: linear-gradient(180deg, var(--tile-top) 49%, var(--tile-border) 49%, var(--tile-border) 51%, var(--tile-bottom) 51%);
  box-shadow: 0 2px 4px #0005, inset 0 1px 0 #fff1;
  transform: rotateX(180deg);
}

/* Scramble state */
.tile.scrambling .tile-front {
  animation: neonCycle 0.4s linear infinite;
}

/* ── Compose area ── */
.compose {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

#messageInput {
  width: 100%;
  padding: 0.8rem 1rem;
  font-family: 'Courier New', Courier, monospace;
  font-size: 1.1rem;
  letter-spacing: 0.1em;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 6px;
  color: #fff;
  outline: none;
  text-transform: uppercase;
}

#messageInput:focus {
  border-color: #555;
}

#messageInput::placeholder {
  color: #444;
}

.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* ── Theme picker ── */
.theme-picker {
  display: flex;
  gap: 6px;
}

.theme-btn {
  width: 32px;
  height: 32px;
  border: 2px solid #333;
  border-radius: 50%;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: border-color 0.2s;
}

.theme-btn span {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: block;
}

.theme-btn.active {
  border-color: #888;
}

.theme-btn:hover {
  border-color: #aaa;
}

/* ── Buttons ── */
.btn {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.9rem;
  letter-spacing: 0.15em;
  padding: 0.65rem 1.5rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: #e0e0e0;
  color: #111;
}
.btn-primary:hover:not(:disabled) { background: #fff; }

.btn-secondary {
  background: #2a2a2a;
  color: #ccc;
  text-decoration: none;
  display: inline-block;
}
.btn-secondary:hover { background: #333; }

/* ── Shared link area ── */
.shared {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.link-box {
  display: flex;
  width: 100%;
  max-width: 500px;
  gap: 0;
}

#linkOutput {
  flex: 1;
  padding: 0.65rem 1rem;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.95rem;
  background: #1a1a1a;
  border: 1px solid #333;
  border-right: none;
  border-radius: 6px 0 0 6px;
  color: #fff;
  outline: none;
}

.btn-copy {
  background: #e0e0e0;
  color: #111;
  border-radius: 0 6px 6px 0;
  white-space: nowrap;
}
.btn-copy:hover { background: #fff; }

/* ── Visitor CTA ── */
.visitor {
  margin-top: 1rem;
}
