:root {
  --bg: #f6f5f1;
  --card-bg: #ffffff;
  --ink: #1a1a1b;
  --muted: #787c7e;
  --border: #d3d6da;
  --accent: #121213;
  --correct: #538d4e;
  --wrong: #b0413e;
  --dot-empty: #e3e3e3;
  --dot-used: #b0413e;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

.page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 16px 48px;
}

body.keyboard-open .page {
  padding: 12px 16px 12px;
}

body.keyboard-open .header,
body.keyboard-open .footer,
body.keyboard-open .message,
body.keyboard-open #next-quote-btn {
  display: none;
}

body.keyboard-open .card {
  padding: 16px 18px;
}

body.keyboard-open .attempts {
  margin-bottom: 12px;
}

body.keyboard-open .quote-wrap {
  margin: 20px 0 16px;
}

body.keyboard-open .author {
  margin: 0 0 12px;
}

body.keyboard-open .guess-form {
  margin-bottom: 0;
}

body.keyboard-open .secondary-actions {
  margin-top: 10px;
}

.header {
  text-align: center;
  margin-bottom: 24px;
}

.header h1 {
  font-size: 2.4rem;
  letter-spacing: 0.05em;
  margin: 0;
  border-bottom: 2px solid var(--border);
  padding-bottom: 8px;
}

.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.card {
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
  padding: 40px 32px;
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.attempts {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--dot-empty);
  transition: background-color 0.3s ease;
}

.dot.used {
  background: var(--dot-used);
}

.quote-wrap {
  position: relative;
  width: 100%;
  max-width: 680px;
  margin: 44px 0 40px;
  display: flex;
  justify-content: center;
  min-height: 1.5em;
}

.quote-wrap::before,
.quote-wrap::after {
  font-family: Georgia, "Times New Roman", serif;
  font-style: normal;
  font-weight: 700;
  font-size: 5rem;
  line-height: 1;
  color: var(--accent);
  opacity: 0.12;
  pointer-events: none;
  user-select: none;
}

.quote-wrap::before {
  content: "\201C";
  position: absolute;
  top: -38px;
  left: -18px;
}

.quote-wrap::after {
  content: "\201D";
  position: absolute;
  bottom: -68px;
  right: -18px;
}

#quote-canvas {
  display: block;
  max-width: 100%;
}

.author {
  margin: 0 0 24px;
  color: var(--muted);
  font-weight: 600;
  font-size: 1rem;
}

.message {
  min-height: 1.4em;
  color: var(--muted);
  font-size: 0.95rem;
  text-align: center;
  margin: 0 0 24px;
}

.guess-form {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 480px;
}

.guess-form input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.guess-form input:focus {
  border-color: var(--accent);
}

.guess-form input:disabled,
.guess-form input:read-only {
  background: #f0f0f0;
  color: var(--muted);
}

.guess-form button {
  padding: 12px 22px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.guess-form button:hover:not(:disabled) {
  background: #000;
}

.guess-form button:active:not(:disabled) {
  transform: scale(0.97);
}

.guess-form button:disabled {
  background: var(--dot-empty);
  cursor: not-allowed;
}

.secondary-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
  justify-content: center;
}

.skip-btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.skip-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.skip-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.skip-btn.hidden {
  display: none;
}

.history {
  width: 100%;
  max-width: 480px;
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-entry {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  background: #f6f5f1;
  border: 1px solid var(--border);
}

.history-entry.incorrect {
  color: var(--wrong);
  border-color: rgba(176, 65, 62, 0.35);
}

.history-entry.correct {
  color: var(--correct);
  border-color: rgba(83, 141, 78, 0.35);
}

.history-entry.invalid {
  color: var(--muted);
  border-style: dashed;
}

.footer {
  margin-top: 32px;
  color: var(--muted);
  font-size: 0.8rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease;
  padding: 16px;
}

.modal-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 36px 32px;
  max-width: 480px;
  width: 100%;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  transform: translateY(12px);
  transition: transform 0.25s ease;
}

.modal-overlay.visible .modal {
  transform: translateY(0);
}

.modal h2 {
  margin: 0 0 20px;
  font-size: 1.8rem;
}

.modal-quote {
  margin: 0 0 12px;
  padding: 0;
  border: none;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, "Courier New", monospace;
  font-style: italic;
  font-size: 1.15rem;
  line-height: 1.6;
  color: var(--ink);
}

.modal-author {
  margin: 0 0 24px;
  color: var(--muted);
  font-weight: 600;
}

.modal button {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.modal button:hover {
  background: #000;
}

@media (max-width: 480px) {
  .card {
    padding: 28px 18px;
  }

  .guess-form {
    flex-direction: column;
  }
}
