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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(180deg, #ffcc70 0%, #ff8c42 100%);
  color: #333;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow-y: auto;
  touch-action: pan-y;
}

#app {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 10px;
}

header {
  display: flex;
  justify-content: space-between;
  padding: 10px 5px;
  font-size: 1.2rem;
  font-weight: bold;
  color: #fff;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

#current-word {
  text-align: center;
  font-size: 1.8rem;
  font-weight: bold;
  color: #fff;
  min-height: 2.5rem;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.3);
  letter-spacing: 0.15em;
}

#grid-wrapper {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px;
}

#grid {
  display: grid;
  gap: 5px;
  width: 100%;
  max-width: 340px;
}

.grid-cell {
  aspect-ratio: 1;
  border-radius: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  font-size: 1.3rem;
  user-select: none;
  transition: transform 0.15s ease;
}

.grid-cell.empty {
  background: transparent;
  border: none;
}

.grid-cell.tile {
  background: #f5e6c8;
  border: 2px solid #e0d0b0;
  color: transparent;
}

.grid-cell.tile.revealed {
  background: #d32f2f;
  border-color: #b71c1c;
  color: #fff;
  transform: scale(1.08);
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.grid-cell.tile.pulse {
  animation: pop 0.3s ease;
}

@keyframes pop {
  0% { transform: scale(1.08); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1.08); }
}

#circle-area {
  position: relative;
  width: 100%;
  max-width: 280px;
  aspect-ratio: 1;
  margin: 5px auto;
}

#connection-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

#circle-letters {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
}

.circle-tile {
  position: absolute;
  width: 18%;
  height: 18%;
  background: #d32f2f;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #fff;
  font-size: 1.5rem;
  font-weight: bold;
  box-shadow: 0 4px 10px rgba(0,0,0,0.25);
  cursor: pointer;
  user-select: none;
  touch-action: none;
  transition: transform 0.1s, background 0.2s;
  transform: translate(-50%, -50%);
}

.circle-tile:active {
  transform: translate(-50%, -50%) scale(0.92);
}

.circle-tile.selected {
  background: #ffc107;
  color: #333;
  transform: translate(-50%, -50%) scale(1.12);
  box-shadow: 0 6px 14px rgba(0,0,0,0.3);
  z-index: 3;
}

.path-line {
  stroke: #ffc107;
  stroke-width: 4;
  stroke-linecap: round;
  fill: none;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,0.2));
}

.temp-line {
  stroke: #ffeb3b;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 4 3;
  fill: none;
}

#controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 10px 0 20px;
}

#controls button {
  padding: 10px 18px;
  border: none;
  border-radius: 24px;
  background: #fff;
  color: #d32f2f;
  font-weight: bold;
  font-size: 1rem;
  box-shadow: 0 3px 8px rgba(0,0,0,0.15);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s;
}

#controls button:hover {
  box-shadow: 0 5px 12px rgba(0,0,0,0.2);
}

#controls button:active {
  transform: scale(0.95);
}

#level-complete {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

#level-complete.hidden {
  display: none;
}

.modal {
  background: #fff;
  padding: 30px 40px;
  border-radius: 16px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal h2 {
  color: #d32f2f;
  margin-bottom: 8px;
  font-size: 1.6rem;
}

.modal p {
  color: #555;
  font-size: 1.1rem;
}
