/* ---- Letter Ascent ---- */

.game-letter-ascent {
  --tile-bg: var(--board-bg);
  --tile-hover: #E4E4E0;
  --tile-selected: var(--accent);
  --tile-path: #C43E41;
  --tile-text: var(--text-bright);
  --tile-text-selected: #fff;
  --valid-color: var(--teal);
  --invalid-color: var(--muted-light);
  --scroll-indicator: var(--gold);
  --glass: rgba(240, 240, 237, 0.85);
  --danger-bg: rgba(221, 76, 79, 0.15);
  --danger-border: rgba(221, 76, 79, 0.3);
  --danger-edge: rgba(221, 76, 79, 0.6);

  padding: 0 4px;
  overflow: hidden;
}

.game-letter-ascent .game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 420px;
  height: 100%;
  min-height: 0;
}

.game-letter-ascent .game-header {
  padding: 2px 0 2px;
}

.game-letter-ascent .game-header h1 {
  font-size: 1.25rem;
}

/* --- STATS --- */

.game-letter-ascent .game-stats {
  gap: 16px;
  margin-bottom: 0;
  flex-shrink: 0;
}

.game-letter-ascent .game-stat-label {
  font-size: 0.6rem;
}

.game-letter-ascent .game-stat {
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.game-letter-ascent .game-stat-value {
  font-family: 'Fredoka', sans-serif;
  font-size: 1rem;
}

/* --- BOARD --- */

.game-letter-ascent .board-container {
  position: relative;
  width: 100%;
  overflow: hidden;
  flex: 1;
  min-height: 0;
}

.game-letter-ascent .board-wrapper {
  width: 100%;
}

.game-letter-ascent .board {
  display: grid;
  gap: 6px;
  justify-content: center;
}

/* --- TILES --- */

.game-letter-ascent .tile {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fredoka', sans-serif;
  font-size: inherit;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--tile-bg);
  color: var(--tile-text);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  position: relative;
  border: 2px solid transparent;
  min-height: 0;
}

.game-letter-ascent .tile:active {
  transform: scale(0.93);
}

.game-letter-ascent .tile.selected {
  background: var(--tile-selected);
  color: var(--tile-text-selected);
  border-color: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(221, 76, 79, 0.3);
  z-index: 2;
}

.game-letter-ascent .tile.path {
  background: var(--tile-path);
  color: var(--tile-text-selected);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 0 12px rgba(221, 76, 79, 0.2);
  z-index: 1;
}

.game-letter-ascent .tile.must-start {
  border-color: rgba(212, 168, 58, 0.45);
  box-shadow: 0 0 7px rgba(212, 168, 58, 0.15);
}

.game-letter-ascent .tile.locked {
  opacity: 0.25;
  pointer-events: none;
}

.game-letter-ascent .tile.consumed {
  opacity: 0.15;
  transform: scale(0.85);
  transition: all 0.3s ease;
}

.game-letter-ascent .tile.advance-zone {
  opacity: 0.55;
}

.game-letter-ascent .tile.advance-zone.selected,
.game-letter-ascent .tile.advance-zone.path {
  opacity: 1;
}

.game-letter-ascent .tile.advance-cutline {
  box-shadow: 0 -3px 0 0 rgba(212, 168, 58, 0.4);
}

.game-letter-ascent .tile.new-tile {
  animation: la-tileAppear 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes la-tileAppear {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.game-letter-ascent .tile .order-badge {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 0.55rem;
  color: rgba(255, 255, 255, 0.6);
  font-family: 'DM Sans', sans-serif;
}

/* --- ROW INDICATOR --- */

.game-letter-ascent .row-indicator {
  position: absolute;
  left: -2px;
  right: -2px;
  top: 0;
  height: calc((100% / 8) - 2px);
  border: 2px dashed var(--scroll-indicator);
  border-radius: 14px;
  opacity: 0.4;
  pointer-events: none;
  transition: opacity 0.3s;
}

.game-letter-ascent .row-indicator.active {
  opacity: 0.8;
}

/* --- DANGER ZONE --- */

.game-letter-ascent .tile.danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: rgba(107, 107, 112, 0.4);
  pointer-events: none;
}

.game-letter-ascent .tile.danger-edge {
  box-shadow: 0 3px 0 0 var(--danger-edge);
}

.game-letter-ascent .board-container.warning {
  animation: la-warningPulse 1s ease-in-out infinite;
}

@keyframes la-warningPulse {
  0%, 100% { box-shadow: inset 0 0 0 0 transparent; }
  50% { box-shadow: inset 0 0 30px rgba(221, 76, 79, 0.1); }
}

/* --- CONTROLS --- */

.game-letter-ascent .controls {
  width: 100%;
  padding: 4px 0;
  padding-bottom: max(4px, env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.game-letter-ascent .controls .game-btn {
  height: var(--tile-size);
  font-size: 0.9rem;
}

.game-letter-ascent .controls .btn-submit {
  flex: 1;
  letter-spacing: 0.1em;
}

.game-letter-ascent .controls .btn-clear {
  width: var(--tile-size);
  flex-shrink: 0;
  font-size: 1.1rem;
}

/* --- TITLE SCREEN --- */

.game-letter-ascent .title-card .overlay-title {
  font-size: 2.4rem;
  color: var(--teal);
}

.game-letter-ascent .title-description {
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.5;
  max-width: 300px;
  margin: 0 auto 16px;
  text-align: center;
}

.game-letter-ascent .title-scoring {
  background: var(--board-bg);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 20px;
  max-width: 280px;
  width: 100%;
}

.game-letter-ascent .title-scoring-heading {
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  color: var(--gold);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.game-letter-ascent .title-scoring-rule {
  color: var(--text);
  font-size: 0.8rem;
  padding: 3px 0;
  line-height: 1.4;
}

/* --- GAME OVER OVERLAY --- */

.game-letter-ascent .game-overlay .overlay-title {
  font-family: 'Fredoka', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}

.game-letter-ascent .game-overlay .score-breakdown {
  width: 100%;
  max-width: 280px;
  max-height: 180px;
  overflow-y: auto;
  margin: 0 auto 12px;
}

.game-letter-ascent .game-overlay .breakdown-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 0.85rem;
  color: var(--muted-light);
  border-bottom: 1px solid var(--muted);
}

.game-letter-ascent .game-overlay .breakdown-label {
  opacity: 0.8;
}

.game-letter-ascent .game-overlay .breakdown-value {
  font-weight: 600;
  color: var(--text-bright);
}

.game-letter-ascent .game-overlay .final-score {
  font-family: 'Fredoka', sans-serif;
  font-size: 3rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 16px;
}


/* --- TOAST --- */

.game-letter-ascent .la-toast {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: var(--surface);
  border: 1px solid var(--teal);
  color: var(--teal);
  padding: 8px 20px;
  border-radius: 10px;
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  z-index: 50;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.game-letter-ascent .la-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --- LOADING OVERLAY --- */

.game-letter-ascent .loading-overlay {
  position: absolute;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  font-family: 'Fredoka', sans-serif;
  color: var(--muted-light);
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: var(--radius);
}

/* --- RESPONSIVE --- */

@media screen and (max-width: 480px) {
  .game-letter-ascent {
    padding: 0 2px;
  }

  .game-letter-ascent .game-stats {
    gap: 16px;
    margin-bottom: 0;
  }

  .game-letter-ascent .game-header {
    padding: 0 0 2px;
  }

  .game-letter-ascent .controls .game-btn {
    font-size: 0.85rem;
  }
}
