*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: #f0ede8;
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 40px;
  padding: 24px;
}

/* ── Counter ── */
.ui {
  align-self: flex-end;
  position: fixed;
  top: 20px;
  right: 28px;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: #2a2a2a;
}

/* ── Map grid — 5 cols × 10 rows ── */
#map {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(10, 1fr);
  gap: 4px;
  width: min(38vw, 240px);
  aspect-ratio: 5 / 10;
}

/* ── Tile base ── */
.tile {
  border-radius: 4px;
  border: 1px solid #d8d4ce;
  background: #f0ede8;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  transition: background 0.25s, border-color 0.25s;
}

.tile-label {
  font-size: clamp(8px, 1.4vw, 13px);
  font-weight: 700;
  letter-spacing: 0.03em;
  color: transparent;
  user-select: none;
}

/* ── Outer-edge bold borders ── */
.tile.outer-top    { border-top-color:    #555; border-top-width:    2px; }
.tile.outer-bottom { border-bottom-color: #555; border-bottom-width: 2px; }
.tile.outer-left   { border-left-color:   #555; border-left-width:   2px; }
.tile.outer-right  { border-right-color:  #555; border-right-width:  2px; }

/* ── Active tile ── */
.tile.active {
  border-color: #4a9e8a;
  border-width: 2px;
  animation: pulse 1.4s ease-in-out infinite;
}

.tile.active .tile-label {
  color: #4a9e8a;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.55; }
}

/* ── Revealed tile — 3 greens (1–3 attempts) + 3 reds (hints needed) ── */
.tile.revealed .tile-label { color: #fff; }

.tile.revealed.result-g1 { background: #1d6b50; border-color: #155840; } /* 1 try  */
.tile.revealed.result-g2 { background: #3d9680; border-color: #2e7a65; } /* 2 tries */
.tile.revealed.result-g3 { background: #6ab89e; border-color: #4e9880; } /* 3 tries */

.tile.revealed.result-r1 { background: #c8885c; border-color: #a86840; } /* just over 3 */
.tile.revealed.result-r2 { background: #c05840; border-color: #a03828; } /* several hints */
.tile.revealed.result-r3 { background: #963020; border-color: #782010; } /* many hints */

/* ── Wrong-answer shake ── */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

.shake {
  animation: shake 0.35s ease-in-out;
}

/* ── Input area ── */
.input-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}

#answer {
  background: #e8e4de;
  border: 1.5px solid #c8c3bb;
  border-radius: 10px;
  outline: none;
  font-size: 1.1rem;
  font-family: inherit;
  font-weight: 500;
  color: #2a2a2a;
  text-align: center;
  width: 260px;
  padding: 8px 16px;
  letter-spacing: 0.02em;
  transition: border-color 0.2s, background 0.2s;
}

#answer:focus {
  border-color: #999;
  background: #e2ddd7;
}

#answer::placeholder {
  color: #bbb;
  font-weight: 400;
}

#completion {
  font-size: 1rem;
  color: #2a2a2a;
  letter-spacing: 0.05em;
}

/* ── Hint display ── */
#hint {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: #888;
  min-height: 1.4em;
  text-align: center;
}

/* ── Practice list ── */
#practice-list {
  width: min(38vw, 240px);
  margin-top: 8px;
}

#practice-heading {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #aaa;
  margin-bottom: 8px;
}

#practice-list table {
  width: 100%;
  border-collapse: collapse;
}

#practice-list td {
  padding: 3px 12px 3px 0;
  font-size: 0.85rem;
  color: #555;
  border: none;
}

#practice-list td:nth-child(odd) {
  font-weight: 700;
  font-family: 'Courier New', Courier, monospace;
  color: #4a9e8a;
  width: 2.5rem;
}

#practice-list td:nth-child(3) {
  padding-left: 1.5rem;
}
