:root {
  /* Wordle-like light palette */
  --bg: #ffffff;
  --panel: #ffffff;
  --text: #121213;
  --muted: #787c7e;
  --key: #d3d6da;
  --key-text: #000000;
  --accent: #6aaa64; /* unused, keep for future */
  --correct: #6aaa64;
  --present: #c9b458;
  --absent: #787c7e;
  --border: #d3d6da;
  --tile-border: #d3d6da;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.title {
  font-weight: 800;
  letter-spacing: 0.5px;
}
.controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.controls select, .btn {
  background: var(--key);
  color: var(--text);
  border: 1px solid var(--tile-border);
  border-radius: 6px;
  padding: 6px 10px;
}
.btn { cursor: pointer; }

.timer {
  min-width: 64px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.best-time {
  min-width: 96px;
  text-align: right;
  color: var(--muted);
}

.app-main {
  max-width: 720px;
  margin: 0 auto;
  display: grid;
  grid-template-rows: 1fr auto auto;
  gap: 16px;
  padding: 16px;
}

.board-wrapper { display: flex; justify-content: center; }
.board {
  display: grid;
  grid-template-columns: repeat(5, 56px);
  grid-template-rows: repeat(6, 56px);
  gap: 8px;
  perspective: 1000px;
}
.tile {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--tile-border);
  font-weight: 800;
  text-transform: uppercase;
  border-radius: 8px;
  user-select: none;
  will-change: transform;
  transform-origin: center center;
  position: relative;
}
.tile .letter {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  will-change: transform;
  transform-origin: center center;
}
.tile.filled { border-color: var(--muted); }
.tile.correct { background: var(--correct); border-color: var(--correct); color: #ffffff; }
.tile.present { background: var(--present); border-color: var(--present); color: #ffffff; }
.tile.absent { background: var(--absent); border-color: var(--absent); color: #ffffff; }

@keyframes flip {
  0% { transform: scaleY(1); }
  40% { transform: scaleY(0.1); }
  50% { transform: scaleY(0); }
  60% { transform: scaleY(0.1); }
  100% { transform: scaleY(1); }
}
.tile.reveal {
  animation: flip 650ms ease-in-out both;
}

/* Keep the letter readable without additional rotation */
.tile.reveal .letter { animation: none; }

/* 3D backface removed in favor of a simple squish */

.keyboard-wrapper { display: flex; justify-content: center; }
.keyboard {
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 8px;
}
.row { display: flex; gap: 8px; justify-content: center; }
.row .spacer { flex: 0.5 1 0; }
.key {
  background: var(--key);
  color: var(--key-text);
  border: 1px solid var(--tile-border);
  border-radius: 6px;
  padding: 12px 10px;
  min-width: 36px;
  cursor: pointer;
  text-transform: uppercase;
}
.key.correct { background: var(--correct); color: #ffffff; border-color: var(--correct); }
.key.present { background: var(--present); color: #ffffff; border-color: var(--present); }
.key.absent { background: var(--absent); color: #ffffff; border-color: var(--absent); }
.key.wide { min-width: 64px; }

/* Share section */
.share[hidden] { display: none; }
.share {
  display: grid;
  gap: 8px;
}
.share-actions { display: flex; justify-content: flex-end; }
.share textarea {
  width: 100%;
  border: 1px solid var(--tile-border);
  border-radius: 8px;
  padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 14px;
  resize: vertical;
}

/* Modal Alert */
.modal[hidden] { display: none; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.35);
}
.modal-content {
  position: absolute;
  left: 50%;
  top: 20%;
  transform: translateX(-50%);
  background: #ffffff;
  color: #121213;
  border: 1px solid var(--tile-border);
  border-radius: 12px;
  width: min(520px, 92vw);
  box-shadow: 0 12px 32px rgba(0,0,0,0.35);
  padding: 16px;
}
.modal-message {
  font-size: 16px;
  line-height: 1.4;
  margin-bottom: 12px;
}
.modal-actions { display: flex; justify-content: flex-end; }

/* Billboard Toast */
.toast {
  position: fixed;
  left: 50%;
  top: 12%;
  transform: translateX(-50%);
  background: #111111;
  color: #ffffff;
  padding: 14px 18px;
  border-radius: 10px;
  border: 1px solid #000000;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  font-weight: 700;
  font-size: 18px;
  line-height: 1.3;
  text-align: center;
  max-width: 90vw;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
  z-index: 1100;
}
.toast.show { opacity: 0.98; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Footer Crosslink */
.app-footer {
  background: var(--panel);
  padding: 12px 16px;
  margin-top: 24px;
}
.crosslink {
  max-width: 720px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 14px;
}
.crosslink a { color: inherit; text-decoration: underline; }

@media (max-width: 480px) {
  .app-main { padding: 12px; max-width: 100%; }
  .board-wrapper { width: 100%; padding: 0 8px; box-sizing: border-box; }
  /* Make grid fill width without causing horizontal overflow */
  .board {
    width: 100%;
    --gap: 6px;
    gap: var(--gap);
    box-sizing: border-box;
    padding: 0;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-template-rows: none; /* override desktop fixed rows */
    grid-auto-rows: auto; /* let aspect-ratio define height */
    overflow: hidden;
  }
  .tile {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    border-radius: 6px;
    max-width: 100%;
  }
  .keyboard-wrapper { padding: 0 8px; width: 100%; }
  .keyboard { gap: 8px; width: 100%; }
  .row { gap: 6px; width: 100%; justify-content: center; }
  .row .spacer { flex: 0.6 1 0; }
  .key { padding: 16px 8px; min-width: 0; flex: 1 1 0; }
  .key.wide { flex: 1.5 1 0; }
}


