@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@700;900&display=swap');

/* ── Palette
   #0D0221  deep space (background)
   #FF10F0  neon pink
   #00F0FF  neon cyan
   #9D00FF  neon purple
──────────────────────────────────────────────────────────────────────────── */

/* ── Base overrides ───────────────────────────────────────────────────────── */
body {
  background: #0D0221;
  touch-action: manipulation;
}

#header {
  background: rgba(8, 1, 22, 0.97);
  border-bottom: 1px solid rgba(255, 16, 240, 0.45);
}

#wu-logo {
  height: 36px;
  width: auto;
  display: block;
  filter:
    brightness(0) invert(1)
    drop-shadow(0 0 6px #FF10F0)
    drop-shadow(0 0 14px rgba(255, 16, 240, 0.55));
}

.icon-btn {
  background: rgba(157, 0, 255, 0.10);
  border-color: rgba(157, 0, 255, 0.55);
  color: #9D00FF;
  text-shadow: 0 0 6px rgba(157, 0, 255, 0.8);
  box-shadow: 0 0 6px rgba(157, 0, 255, 0.2), inset 0 0 5px rgba(157, 0, 255, 0.06);
}
.icon-btn:hover:not(:disabled) {
  background: rgba(157, 0, 255, 0.22);
  border-color: #9D00FF;
  color: #bf40ff;
  box-shadow: 0 0 12px rgba(157, 0, 255, 0.45);
}
.icon-btn:active:not(:disabled) {
  background: rgba(157, 0, 255, 0.35);
  color: #d080ff;
}

/* Directions modal — override shared dark-slate colours to neon palette */
.directions-modal {
  background: #100228;
  border-color: rgba(157, 0, 255, 0.55);
  box-shadow: 0 0 40px rgba(157, 0, 255, 0.35), 0 20px 60px rgba(0, 0, 0, 0.75);
}
.dir-heading {
  color: #FF10F0;
  text-shadow: 0 0 10px rgba(255, 16, 240, 0.6);
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  letter-spacing: 0.06em;
}
.dir-pane { color: rgba(0, 240, 255, 0.82); }
.dir-close-btn {
  background: #FF10F0;
  box-shadow: 0 0 12px rgba(255, 16, 240, 0.65);
  color: #0D0221;
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.dir-close-btn:hover  { background: #ff44f4; box-shadow: 0 0 18px rgba(255, 16, 240, 0.85); }
.dir-close-btn:active { background: #cc00c0; }

/* ── Canvas / play area ───────────────────────────────────────────────────── */
#canvas-wrap {
  background:
    radial-gradient(ellipse 90% 45% at 50% 105%, rgba(157, 0, 255, 0.28) 0%, transparent 68%),
    linear-gradient(180deg, #0D0221 0%, #120136 100%);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 20px 12px calc(20px + env(safe-area-inset-bottom, 0px));
  position: relative;
  overflow: hidden;
}

/* Scanlines */
#canvas-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent        0px,
    transparent        3px,
    rgba(0,0,0,0.18)   3px,
    rgba(0,0,0,0.18)   4px
  );
  pointer-events: none;
  z-index: 0;
}

/* Horizon grid */
#canvas-wrap::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 30%;
  background:
    linear-gradient(to top, rgba(157,0,255,0.10) 0%, transparent 100%),
    linear-gradient(90deg,       rgba(157,0,255,0.22) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(to bottom,   rgba(157,0,255,0.22) 1px, transparent 1px) 0 0 / 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* ── Game container ───────────────────────────────────────────────────────── */
#wu-game {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: 100%;
}

/* ── Board wrap (grid + SVG share this layer) ─────────────────────────────── */
.wu-board-wrap {
  position: relative;
  width:  min(304px, calc(100vw - 32px));
  height: min(304px, calc(100vw - 32px));
  flex-shrink: 0;
}

/* ── 3×3 letter grid ──────────────────────────────────────────────────────── */
.wu-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 1;
}

/* ── SVG trace overlay ────────────────────────────────────────────────────── */
.wu-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  overflow: visible;
}

/* ── Letter cells ─────────────────────────────────────────────────────────── */
.wu-cell {
  background: rgba(13, 2, 33, 0.72);
  border: 2px solid #FF10F0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: clamp(1.45rem, 6.2vw, 2.1rem);
  color: #00F0FF;
  text-shadow:
    0 0  7px #00F0FF,
    0 0 18px rgba(0, 240, 255, 0.55);
  box-shadow:
    0 0  8px rgba(255, 16, 240, 0.55),
    0 0 18px rgba(255, 16, 240, 0.20),
    inset 0 0 8px rgba(255, 16, 240, 0.08);
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  transition: box-shadow 0.08s, color 0.08s, background 0.08s, transform 0.06s;
  position: relative;
  z-index: 1;
}

/* Disambiguation underline for rotation-confusable letters (Z↔N, M↔W).
   Pseudo-element lives inside the rotating cell so it always marks the
   letter's true bottom regardless of which orientation the tile is in. */
.wu-cell--ul::after {
  content: '';
  position: absolute;
  top: calc(50% + 0.5em);
  left: 50%;
  transform: translateX(-50%);
  width: 0.55em;
  height: 2px;
  background: #00F0FF;
  border-radius: 1px;
  opacity: 0.85;
  pointer-events: none;
  box-shadow: 0 0 5px #00F0FF, 0 0 10px rgba(0, 240, 255, 0.45);
}

/* Qu needs a touch less size so it fits in the cell */
.wu-cell--qu {
  font-size: clamp(1.05rem, 4.6vw, 1.55rem);
  letter-spacing: -0.02em;
}

/* Per-tile tumble rotation classes */
.wu-r90  { transform: rotate(90deg); }
.wu-r180 { transform: rotate(180deg); }
.wu-r270 { transform: rotate(270deg); }

/* Slow transition only during the 10s tumble — keeps tap-scale snappy */
.wu-cell.wu-tumbling {
  transition: box-shadow 0.08s, color 0.08s, background 0.08s,
              transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.wu-cell:active:not(.wu-used):not(.wu-active) {
  transform: scale(0.90);
}

/* Used — part of the trace but not the tail */
.wu-cell.wu-used {
  background: rgba(255, 16, 240, 0.10);
  border-color: rgba(255, 16, 240, 0.38);
  color: rgba(0, 240, 255, 0.35);
  text-shadow: none;
  box-shadow: none;
  cursor: default;
}

/* Active — the current tail */
.wu-cell.wu-active {
  background: rgba(255, 16, 240, 0.20);
  border: 3px solid #FF10F0;
  color: #fff;
  text-shadow:
    0 0 10px #FF10F0,
    0 0 24px rgba(255, 16, 240, 0.7);
  box-shadow:
    0 0 16px rgba(255, 16, 240, 0.9),
    0 0 32px rgba(255, 16, 240, 0.4),
    inset 0 0 12px rgba(255, 16, 240, 0.15);
  cursor: default;
}

/* Submit flash — briefly applied to all trace cells on word submit */
.wu-cell.wu-submitted {
  border-color: #00F0FF !important;
  color: #fff !important;
  text-shadow: 0 0 12px #00F0FF !important;
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.85) !important;
  animation: wu-submit-flash 0.32s ease-out forwards;
}

@keyframes wu-submit-flash {
  0%   { background: rgba(0, 240, 255, 0.30); transform: scale(1.06); }
  100% { background: rgba(13, 2, 33, 0.72);   transform: scale(1); }
}

/* Grid pop on rotate */
.wu-grid.wu-rotating {
  animation: wu-grid-pop 0.18s ease-out forwards;
}

@keyframes wu-grid-pop {
  0%   { opacity: 0.5; transform: scale(0.92); }
  65%  { opacity: 1;   transform: scale(1.02); }
  100% { opacity: 1;   transform: scale(1); }
}

/* ── Controls row ─────────────────────────────────────────────────────────── */
.wu-controls {
  display: flex;
  align-items: center;
  justify-content: center;
}

.wu-rotate-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(13, 2, 33, 0.70);
  border: 2px solid #FF10F0;
  border-radius: 10px;
  color: #FF10F0;
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  padding: 10px 22px;
  cursor: pointer;
  text-shadow: 0 0 6px rgba(255, 16, 240, 0.65);
  box-shadow:
    0 0 8px rgba(255, 16, 240, 0.30),
    inset 0 0 6px rgba(255, 16, 240, 0.05);
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s, box-shadow 0.1s, transform 0.06s;
}

.wu-rotate-icon {
  font-size: 1rem;
  line-height: 1;
  display: inline-block;
  transition: transform 0.35s ease;
}

.wu-rotate-btn:hover {
  background: rgba(255, 16, 240, 0.10);
  box-shadow: 0 0 14px rgba(255, 16, 240, 0.55);
}

.wu-rotate-btn:active {
  transform: scale(0.94);
  background: rgba(255, 16, 240, 0.18);
}

/* Spin the arrow icon 90° each click */
.wu-rotate-btn[data-rot="1"] .wu-rotate-icon { transform: rotate(90deg); }
.wu-rotate-btn[data-rot="2"] .wu-rotate-icon { transform: rotate(180deg); }
.wu-rotate-btn[data-rot="3"] .wu-rotate-icon { transform: rotate(270deg); }
.wu-rotate-btn[data-rot="0"] .wu-rotate-icon { transform: rotate(360deg); }

/* ── Status bar (timer + score) ───────────────────────────────────────────── */
.wu-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(304px, calc(100vw - 32px));
}

.wu-timer {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 1.5rem;
  letter-spacing: 0.04em;
  color: #00F0FF;
  text-shadow:
    0 0 10px rgba(0, 240, 255, 0.7),
    0 0 24px rgba(0, 240, 255, 0.35);
  min-width: 3rem;
}

.wu-timer--urgent {
  color: #FF10F0;
  text-shadow:
    0 0 10px rgba(255, 16, 240, 0.9),
    0 0 24px rgba(255, 16, 240, 0.5);
  animation: wu-timer-pulse 0.7s ease-in-out infinite alternate;
}

@keyframes wu-timer-pulse {
  from { opacity: 0.65; }
  to   { opacity: 1; }
}

.wu-score-display {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 1.2rem;
  color: #FF10F0;
  text-shadow: 0 0 8px rgba(255, 16, 240, 0.65);
  text-align: right;
}

.wu-pts-label {
  font-size: 0.6rem;
  letter-spacing: 0.09em;
  opacity: 0.65;
}

/* ── Pre-game splash screen (covers full canvas on load) ──────────────────── */
#wu-splash {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: rgba(8, 1, 22, 0.98);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 32px 28px;
  overflow-y: auto;
}

.wu-splash-logo {
  height: 40px;
  width: auto;
  display: block;
  flex-shrink: 0;
  filter:
    brightness(0) invert(1)
    drop-shadow(0 0 8px #FF10F0)
    drop-shadow(0 0 20px rgba(255, 16, 240, 0.6));
}

.wu-splash-text {
  color: rgba(0, 240, 255, 0.82);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  line-height: 1.65;
  text-align: center;
  max-width: 300px;
  margin: 0;
}

.wu-start-btn {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 1.45rem;
  letter-spacing: 0.14em;
  color: #0D0221;
  background: #FF10F0;
  border: none;
  border-radius: 12px;
  padding: 16px 40px;
  cursor: pointer;
  box-shadow:
    0 0 28px rgba(255, 16, 240, 0.85),
    0 0 56px rgba(255, 16, 240, 0.35);
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s, box-shadow 0.1s, transform 0.06s, opacity 0.2s;
}

.wu-start-btn:hover {
  background: #ff44f4;
  box-shadow: 0 0 36px rgba(255, 16, 240, 1), 0 0 72px rgba(255, 16, 240, 0.5);
}

.wu-start-btn:active {
  transform: scale(0.94);
  background: #cc00c0;
}

.wu-start-btn:disabled {
  opacity: 0.5;
  cursor: default;
  box-shadow: none;
}

/* ── Feedback flash ───────────────────────────────────────────────────────── */
.wu-feedback {
  min-height: 26px;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.77rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-align: center;
  color: transparent;
  transition: color 0.12s, text-shadow 0.12s;
}

.wu-feedback--valid {
  color: #00F0FF;
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.65);
}

.wu-feedback--bonus {
  color: #FFD700;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.85), 0 0 22px rgba(255, 215, 0, 0.4);
  font-size: 0.88rem;
}

.wu-feedback--invalid {
  color: #FF5555;
  text-shadow: 0 0 8px rgba(255, 85, 85, 0.65);
}

.wu-feedback--duplicate {
  color: #9D00FF;
  text-shadow: 0 0 8px rgba(157, 0, 255, 0.65);
}

.wu-feedback--short {
  color: rgba(255, 255, 255, 0.35);
}

/* ── Found-words list ─────────────────────────────────────────────────────── */
.wu-found-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
  width: min(304px, calc(100vw - 32px));
  max-height: 82px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 0;
  align-content: flex-start;
}

/* Word chips */
.wu-word-chip {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.60rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid;
  white-space: nowrap;
  line-height: 1.4;
}

.wu-word-chip--short {
  color: rgba(0, 240, 255, 0.75);
  border-color: rgba(0, 240, 255, 0.28);
  background: rgba(0, 240, 255, 0.05);
}

.wu-word-chip--long {
  color: #FF10F0;
  border-color: rgba(255, 16, 240, 0.38);
  background: rgba(255, 16, 240, 0.07);
}

.wu-word-chip--bonus {
  color: #FFD700;
  border-color: rgba(255, 215, 0, 0.45);
  background: rgba(255, 215, 0, 0.09);
  box-shadow: 0 0 6px rgba(255, 215, 0, 0.22);
}

/* ── End-of-round overlay ─────────────────────────────────────────────────── */
.wu-end-overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 1, 22, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wu-end-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 28px 24px 32px;
  width: min(320px, calc(100vw - 24px));
  text-align: center;
}

.wu-end-title {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 1.55rem;
  letter-spacing: 0.12em;
  color: #FF10F0;
  text-shadow:
    0 0 16px rgba(255, 16, 240, 0.85),
    0 0 36px rgba(255, 16, 240, 0.4);
  margin: 0;
}

.wu-end-score-block {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.wu-end-score-val {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 3.2rem;
  color: #00F0FF;
  text-shadow:
    0 0 20px rgba(0, 240, 255, 0.85),
    0 0 44px rgba(0, 240, 255, 0.4);
  line-height: 1;
}

.wu-end-score-suffix {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  color: rgba(0, 240, 255, 0.55);
  letter-spacing: 0.09em;
}

.wu-end-word-count {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.45);
  margin: 0;
  letter-spacing: 0.03em;
}

.wu-end-words {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
  max-height: 130px;
  overflow-y: auto;
  width: 100%;
  padding: 2px 0;
}

/* Best score line */
.wu-end-best {
  min-height: 22px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  color: rgba(0, 240, 255, 0.50);
  letter-spacing: 0.02em;
}

.wu-end-best--new {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 0.82rem;
  letter-spacing: 0.10em;
  color: #FFD700;
  text-shadow:
    0 0 10px rgba(255, 215, 0, 0.85),
    0 0 24px rgba(255, 215, 0, 0.4);
}

/* Action row */
.wu-end-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 4px;
}

.wu-play-again-btn {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 0.82rem;
  letter-spacing: 0.11em;
  color: #0D0221;
  background: #FF10F0;
  border: none;
  border-radius: 10px;
  padding: 13px 22px;
  cursor: pointer;
  box-shadow: 0 0 18px rgba(255, 16, 240, 0.7);
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s, box-shadow 0.1s, transform 0.06s;
}

.wu-play-again-btn:hover  { background: #ff44f4; box-shadow: 0 0 26px rgba(255, 16, 240, 0.9); }
.wu-play-again-btn:active { transform: scale(0.94); background: #cc00c0; }

/* Share button */
.wu-share-btn {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 0.82rem;
  letter-spacing: 0.11em;
  color: #00F0FF;
  background: rgba(0, 240, 255, 0.07);
  border: 2px solid #00F0FF;
  border-radius: 10px;
  padding: 11px 22px;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.30);
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s, box-shadow 0.1s, transform 0.06s;
}

.wu-share-btn:hover  { background: rgba(0, 240, 255, 0.15); box-shadow: 0 0 18px rgba(0, 240, 255, 0.55); }
.wu-share-btn:active { transform: scale(0.94); background: rgba(0, 240, 255, 0.22); }

/* ── Utility ──────────────────────────────────────────────────────────────── */
.wu-hide { display: none !important; }
