:root {
  --bg: var(--bg-dark);
  --card-bg: var(--bg-card);
  --card-border: var(--border-light);
  --text: var(--text-main);
  --accent: #ffb703;
  --accent-2: #56cfe1;
  --shadow: 0 25px 45px rgba(0, 0, 0, 0.25);
}



.top-controls {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.top-controls button {
  margin: 0;
  padding: 0.45rem 1.1rem;
}

.settings-panel {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 18px;
  padding: 1rem 1.5rem;
  margin-bottom: 1.5rem;
  display: none;
  gap: 1rem;
  flex-wrap: wrap;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

[data-theme="light"] .settings-panel {
  background: rgba(255, 255, 255, 0.8);
  border-color: rgba(0, 0, 0, 0.1);
}

.settings-panel.open {
  display: flex;
}

.settings-panel label {
  font-weight: 600;
  font-size: 0.9rem;
}

.settings-panel .field {
  flex: 1;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.settings-panel select,
.settings-panel input {
  margin-bottom: 0;
  border-radius: 12px;
  padding: 0.5rem 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(5, 5, 5, 0.2);
  color: var(--text);
}

[data-theme="light"] .settings-panel select,
[data-theme="light"] .settings-panel input {
  background: rgba(255, 255, 255, 0.5);
  border-color: rgba(0, 0, 0, 0.2);
  color: var(--text);
}


h1 {
  font-size: clamp(2rem, 4vw, 3.8rem);
  letter-spacing: -0.03em;
}

header p {
  margin-top: 0.75rem;
  opacity: 0.8;
  font-size: 1.1rem;
}


*:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
.memory-card:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}


button,
input[type="button"],
input[type="submit"] {
  min-height: 44px;
}

main {
  max-width: 1100px;
  margin: 0 auto;
}

.tab-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1.8rem;
  padding: 0.4rem;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(12px);
}

[data-theme="light"] .tab-nav {
  background: rgba(255, 255, 255, 0.6);
  border-color: rgba(0, 0, 0, 0.1);
}

.tab-nav button {
  border: none;
  border-radius: 999px;
  padding: 0.6rem 1.3rem;
  background: transparent;
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s ease, background 0.2s ease;
}

.tab-nav button.active {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #0b132b;
  opacity: 1;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  animation: fadeIn 0.35s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 22px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  position: relative;
  overflow: hidden;
}

.card h2 {
  font-size: 1.4rem;
  margin-bottom: 1rem;
}

button,
input,
select {
  font: inherit;
}

button {
  border: none;
  cursor: pointer;
  border-radius: 999px;
  padding: 0.6rem 1.4rem;
  margin: 0.25rem;
  font-weight: 600;
  transition: transform 0.15s ease, opacity 0.15s ease;
  background: linear-gradient(135deg, var(--accent), #ff7d00);
  color: #0a192f;
}

button.secondary {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text);
}

[data-theme="light"] button.secondary {
  background: rgba(0, 0, 0, 0.1);
  color: var(--text);
}


button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button:not(:disabled):hover {
  transform: translateY(-1px) scale(1.02);
}

input[type="text"],
input[type="number"],
input[type="password"] {
  width: 100%;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.6rem 1rem;
  background: rgba(5, 5, 5, 0.2);
  color: var(--text);
  margin-bottom: 0.75rem;
}

[data-theme="light"] input[type="text"],
[data-theme="light"] input[type="number"],
[data-theme="light"] input[type="password"] {
  background: rgba(255, 255, 255, 0.5);
  border-color: rgba(0, 0, 0, 0.2);
  color: var(--text);
}


[data-theme="light"] .calc-config {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .calc-ops-group label {
  background: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .calc-ops-group label:hover {
  background: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .center-stats span {
  background: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .calc-input-display input {
  background: #ffffff;
  color: #000000;
  border-color: var(--accent);
}

[data-theme="light"] .numpad-btn {
  background: #ffffff;
  color: #1a1a1a;
  border: 2px solid rgba(0, 0, 0, 0.2);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .numpad-btn:hover {
  background: #f5f5f5;
  color: #000000;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .numpad-btn:active,
[data-theme="light"] .numpad-btn.active {
  background: var(--accent);
  color: #000000;
}

[data-theme="light"] .numpad-btn.action-btn {
  background: #ffe0e0;
  color: #c92a2a;
}

[data-theme="light"] .calc-timer-large {
  text-shadow: none;
}

[data-theme="light"] .game-instruction {
  color: rgba(0, 0, 0, 0.7);
}




.calc-timer-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 0.5rem;
  width: 100%;
}

@media (max-width: 600px) {
  .calc-timer-row {
    gap: 0.5rem;
  }
}

.calc-sidebar-stats {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  text-align: left;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.05);
  padding: 0.25rem 0.75rem;
  border-radius: 8px;
  white-space: nowrap;
}

@media (max-width: 600px) {
  .stat-item {
    font-size: 0.8rem;
    padding: 0.2rem 0.5rem;
    gap: 0.25rem;
  }

  .stat-item strong {
    font-size: 1rem;
  }
}

.stat-item strong {
  font-size: 1.25rem;
  color: var(--accent);
}

[data-theme="light"] .stat-item {
  background: rgba(0, 0, 0, 0.05);
}


.center-stats {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  flex-wrap: wrap;
}

.center-stats span {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
}

.center-stats strong {
  font-size: 1.4rem;
  color: var(--accent);
  min-width: 2ch;
  text-align: center;
}


.calc-config {
  background: rgba(255, 255, 255, 0.05);
  padding: 1rem;
  border-radius: 12px;
  margin-bottom: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  width: 100%;
  max-width: 550px;
  margin-left: auto;
  margin-right: auto;
}

.calc-config label {
  font-size: 1.1rem;
  font-weight: 600;
  display: block;
  margin-bottom: 0.25rem;
}

.calc-config input[type="number"] {
  font-size: 1.25rem;
  padding: 0.5rem;
  width: 100%;
  max-width: 150px;
  text-align: center;
  font-weight: 600;
}


.calc-ops-group {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;

  margin-top: 1rem;
  justify-content: center;
  font-size: 2rem;

  font-weight: 700;
  width: 100%;
  max-width: 100%;

}

.calc-ops-group label {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 0.5rem;

  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  transition: background 0.2s;
  width: 100%;
  min-width: 0;

}

.calc-ops-group label:hover {
  background: rgba(255, 255, 255, 0.1);
}

.calc-ops-group input {
  margin: 0;
  width: 1.5rem;
  height: 1.5rem;
  cursor: pointer;
}

#calc-reset-record {
  font-size: 1.5rem;
  width: 2rem;
  height: 2rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  vertical-align: middle;
}

@media (max-width: 600px) {
  .calc-ops-group {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    font-size: 1.8rem;

    margin-top: 0.75rem;
  }

  .calc-ops-group label {
    padding: 0.5rem;
    gap: 0.5rem;
  }

  .calc-ops-group input {
    width: 1.25rem;
    height: 1.25rem;
  }
}

.calc-game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.calc-timer-large {
  font-size: 4rem;
  font-family: 'Courier New', monospace;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.25rem;
  text-shadow: 0 0 20px rgba(255, 165, 0, 0.3);
  letter-spacing: 0.1em;
  line-height: 1;
}

@media (max-width: 600px) {
  .calc-timer-large {
    font-size: 2.5rem;

    letter-spacing: 0;
  }

  .center-stats {
    gap: 0.5rem;
    font-size: 0.9rem;
  }

  .center-stats strong {
    font-size: 1.1rem;
  }

  .center-stats span {
    padding: 0.25rem 0.5rem;
  }
}

.calc-question {
  font-size: 4rem;
  font-weight: 800;
  margin: 0.5rem 0;
  min-height: 5rem;
  text-align: center;
  line-height: 1.2;
}

.calc-input-display input {
  font-size: 3rem;
  text-align: center;
  width: 260px;
  padding: 0.25rem 0.5rem;
  background: rgba(0, 0, 0, 0.3);
  border: 3px solid var(--accent);
  border-radius: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  height: auto;
}

.calc-numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 2rem;
  width: 100%;
  max-width: 400px;
}

.numpad-btn {
  font-size: 2.5rem;
  font-weight: 700;
  padding: 1.25rem;
  aspect-ratio: 1;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
  transition: all 0.15s;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.numpad-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.numpad-btn:active,
.numpad-btn.active {
  transform: scale(0.95);
  background: var(--accent);
}

.numpad-btn.action-btn {
  background: rgba(255, 100, 100, 0.2);
  color: #ff6b6b;
}

.feedback-overlay {
  position: absolute;
  top: 70%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 10;
  display: flex;
  justify-content: center;
  align-items: center;
}

.feedback-icon {
  font-size: 8rem;
  opacity: 0;
  transform: scale(0.5);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.feedback-icon.show {
  opacity: 1;
  transform: scale(1);
}

/* Fullscreen Button */
.btn-fullscreen {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(0, 0, 0, 0.3);
  color: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  width: 40px;
  height: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  z-index: 10;
  transition: all 0.2s ease;
}

[data-theme="light"] .btn-fullscreen {
  background: rgba(255, 255, 255, 0.5);
  color: rgba(0, 0, 0, 0.6);
  border-color: rgba(0, 0, 0, 0.1);
}

.btn-fullscreen:hover {
  background: var(--accent);
  color: #000;
  transform: scale(1.1);
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.game-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
  padding-right: 3rem;
  /* Make space for the absolute button */
}

.game-title {
  flex: 1;
  min-width: 0;
}

.game-title h2 {
  margin-bottom: 0.5rem;
}

.game-title p {
  margin-bottom: 0;
}

.cog-plot {
  display: grid;
  gap: 0;
  justify-items: center;
  flex: 0 0 240px;
}

.cog-title {
  justify-self: center;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.7;
}

.cog-chart {
  width: 100%;
}

.cog-svg {
  width: 100%;
  max-width: 240px;
  height: auto;
  margin-top: -3rem;
}

.cog-grid {
  fill: none;
  stroke: rgba(255, 255, 255, 0.12);
  stroke-width: 1;
}

[data-theme="light"] .cog-grid {
  stroke: rgba(0, 0, 0, 0.12);
}


.cog-axis {
  stroke: rgba(255, 255, 255, 0.14);
  stroke-width: 1;
}

[data-theme="light"] .cog-axis {
  stroke: rgba(0, 0, 0, 0.14);
}


.cog-shape {
  fill: rgba(128, 255, 219, 0.2);
  stroke: #80ffdb;
  stroke-width: 2;
}

[data-theme="light"] .cog-shape {
  fill: rgba(0, 150, 136, 0.2);
  stroke: #009688;
}


.cog-label {
  font-size: 13px;

  font-weight: 500;
  fill: rgba(255, 255, 255, 0.7);
}

[data-theme="light"] .cog-label {
  fill: rgba(0, 0, 0, 0.7);
}


@media (max-width: 900px) {
  .game-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .cog-plot {
    align-self: flex-start;
  }
}

@media (max-width: 540px) {
  .cog-svg {
    max-width: 200px;
  }
}

.stats {
  margin: 0.75rem 0 1rem;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.stats strong.timer {
  font-variant-numeric: tabular-nums;
  display: inline-block;
  min-width: 8ch;
  text-align: right;
  font-family: inherit;
}

.stroop-word {
  font-size: 2.4rem;
  font-weight: 700;
  text-transform: uppercase;
  text-align: center;
  letter-spacing: 0.05em;
  margin: 1rem 0;
  min-height: 3rem;
}

.stroop-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 0.75rem;
}

.stroop-buttons button {
  border-radius: 16px;
  color: #0a192f;
  font-weight: 700;
  padding: 0.75rem 0.5rem;
}

.quiz-options {
  display: grid;
  gap: 0.8rem;
  margin: 1rem 0;
}

.quiz-options button {
  width: 100%;
  border-radius: 15px;
  text-align: left;
  padding: 0.9rem 1rem;
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
  border: 1px solid transparent;
}

[data-theme="light"] .quiz-options button {
  background: rgba(0, 0, 0, 0.08);
}


.quiz-options button.correct {
  border-color: #80ffdb;
  color: #80ffdb;
}

[data-theme="light"] .quiz-options button.correct {
  border-color: #009688;
  color: #00796b;
}



.sequence-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;

  width: 100%;
  max-width: 500px;

  margin: 1.5rem auto;

}

.sequence-controls {
  margin-top: 1.5rem;
  display: flex;
  justify-content: center;
}

.sequence-btn {
  width: 100%;
  height: 100%;
  border-radius: 1.5rem;
  border: none;
  margin: 0;
  cursor: pointer;
  opacity: 1;

  background: var(--color);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
  transition: opacity 0.1s, transform 0.1s, box-shadow 0.1s;
  aspect-ratio: 1;
}

.sequence-btn:hover {
  filter: brightness(1.1);
}

.sequence-btn.green {
  --color: #45ca55;

}

.sequence-btn.red {
  --color: #eb4a60;

}

.sequence-btn.yellow {
  --color: #f3e92c;

}

.sequence-btn.blue {
  --color: #428ae2;

}

.sequence-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
  opacity: 1;
  filter: brightness(1.2);
}

.sequence-btn.lit {
  opacity: 1;
  filter: brightness(1.4) drop-shadow(0 0 15px var(--color));
  transform: scale(0.98);
}

.quiz-options button.wrong {
  border-color: #ff5d8f;
  color: #ff5d8f;
  opacity: 0.8;
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.memory-card {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  padding: 1.5rem;
  text-align: center;
  font-size: 3rem;
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.2);
  transition: transform 0.15s ease, border-color 0.15s ease;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

[data-theme="light"] .memory-card {
  background: rgba(0, 0, 0, 0.08);
  border-color: rgba(0, 0, 0, 0.2);
}

.memory-card:hover:not(.matched) {
  transform: scale(1.05);
  border-color: var(--accent);
}

.memory-card.revealed {
  border-color: var(--accent-2);
  background: rgba(86, 207, 225, 0.3);
  border-width: 3px;
}

.memory-card.matched {
  border-color: #80ed99;
  background: rgba(128, 237, 153, 0.3);
  cursor: default;
  border-width: 3px;
}

[data-theme="light"] .memory-card.matched {
  border-color: #2e7d32;
  background: rgba(46, 125, 50, 0.1);
}


.memory-config {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.memory-config label {
  font-size: 0.9rem;
  opacity: 0.8;
}

.memory-config input {
  width: 90px;
  margin-bottom: 0;
}

.keyword-config {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.keyword-config label {
  font-size: 0.9rem;
  opacity: 0.8;
}

#keyword-input {
  flex: 1;
  min-width: 220px;
  margin-bottom: 0;
}

#keyword-count {
  width: 110px;
  margin-bottom: 0;
}

.keyword-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.keyword-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.keyword-grid img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

#keyword-reveal-text {
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  margin: 1rem 0;
  color: #ffffff;
  letter-spacing: 0.02em;
}

[data-theme="light"] #keyword-reveal-text {
  color: var(--text);
}


.guessword-word {
  font-size: 2.4rem;
  font-weight: 700;
  text-align: center;
  margin: 1.25rem 0;
  letter-spacing: 0.18em;
}

.guessword-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 0.75rem;
}

.guessword-field label {
  display: block;
  font-size: 0.9rem;
  opacity: 0.8;
  margin-bottom: 0.35rem;
}

.guessword-field input {
  margin-bottom: 0;
}

.guessword-status {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  font-size: 1rem;
  opacity: 0.85;
}

.guessword-remaining {
  font-size: 1.6rem;
  font-weight: 700;
  color: #ffffff;
}

[data-theme="light"] .guessword-remaining {
  color: var(--text);
}


.guessword-keyboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(52px, 1fr));
  gap: 0.65rem;
  margin-top: 1rem;
}

.guessword-key {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--text);
  border-radius: 12px;
  padding: 0.7rem 0;
  min-height: 46px;
  font-weight: 600;
  font-size: 1.05rem;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

[data-theme="light"] .guessword-key {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.1);
}


.guessword-key:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.35);
}

.guessword-key:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(1);
  transform: none;
}

@media (max-width: 720px) {
  .keyword-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  .keyword-grid {
    grid-template-columns: 1fr;
  }

  .keyword-grid img {
    height: 200px;
  }
}

.calc-config {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.calc-config label {
  font-size: 0.9rem;
  opacity: 0.8;
}

.calc-config input {
  width: 110px;
  margin-bottom: 0;
}

#trivia-difficulty {
  background: rgba(5, 5, 5, 0.2);
  color: var(--text);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

[data-theme="light"] #trivia-difficulty {
  background: rgba(255, 255, 255, 0.5);
  border-color: rgba(0, 0, 0, 0.2);
}


.calc-ops {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  opacity: 0.85;
}

.calc-ops label {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-weight: 600;
  opacity: 1;
}

.calc-ops input[type="checkbox"] {
  accent-color: var(--accent);
}

.calc-question {
  font-size: 3rem;
  text-align: center;
  margin: 1rem 0;
  font-weight: 700;
}

.calc-input {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.calc-input input {
  margin-bottom: 0;
  flex: 1;
  font-size: 1.5rem;
  font-weight: 600;
}

.helper-text {
  font-size: 0.85rem;
  opacity: 0.75;
  margin-bottom: 0.6rem;
}

footer {
  margin-top: 3rem;
  text-align: center;
  opacity: 0.65;
  font-size: 0.95rem;
}

.page-shell {
  padding: 2rem clamp(1rem, 3vw, 4rem) 3rem;
}


@media (max-width: 640px) {
  .page-shell {
    padding: 1rem 0.75rem 1.5rem;
  }

  header {
    margin-top: 1rem;
  }
}


.sketch-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.sketch-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  padding: 0.75rem;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  flex-wrap: wrap;
}

[data-theme="light"] .sketch-controls {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.1);
}


.btn-tool {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  transition: all 0.2s ease;
  padding: 0;
  margin: 0;
}

[data-theme="light"] .btn-tool {
  background: rgba(0, 0, 0, 0.1);
}


.btn-tool:hover {
  background: rgba(255, 255, 255, 0.2);
}

[data-theme="light"] .btn-tool:hover {
  background: rgba(0, 0, 0, 0.2);
}


.btn-tool.active {
  background: var(--accent);
  color: #0a192f;
}

.btn-tool.danger:hover {
  background: #ff5d8f;
  color: white;
}

.brush-size {
  flex: 1;
  min-width: 100px;
  display: flex;
  align-items: center;
  padding: 0 0.5rem;
}

.brush-size input {
  width: 100%;
  accent-color: var(--accent);
  margin: 0;
}

#sketch-color {
  width: 42px;
  height: 42px;
  padding: 0;
  border: none;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
}

.canvas-wrapper {
  position: relative;
  width: 100%;
  background: #000;
  border-radius: 18px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  overflow: hidden;
  aspect-ratio: 1 / 1;
  max-height: 600px;
  display: flex;
  flex-direction: column;
}

[data-theme="light"] .canvas-wrapper {
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}


#sketch-canvas {
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}


.game-instruction {
  margin-top: 1rem;
  white-space: pre-line;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.95rem;
  line-height: 1.6;
}



.hidden {
  display: none !important;
}

.numberdash-result {
  text-align: center;
  padding: 2rem;
  animation: fadeIn 0.5s ease;
}

.result-title {
  font-size: 3rem;
  margin-bottom: 1rem;
  color: var(--accent);
}

.result-stats {
  margin: 2rem 0;
}

.result-time {
  font-size: 4rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 0.5rem;
}

.result-errors {
  font-size: 1.2rem;
  opacity: 0.8;
  margin-bottom: 0.25rem;
}

.result-error-val {
  font-size: 2rem;
  font-weight: 700;
}

.numberdash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
  justify-content: center;
}

.numberdash-btn {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 2rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
}

[data-theme="light"] .numberdash-btn {
  border-color: rgba(0, 0, 0, 0.2);
  background: rgba(0, 0, 0, 0.05);
  color: var(--text);
}

.numberdash-btn:hover {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  transform: scale(1.1);
}

.numberdash-btn.clicked {
  opacity: 0.3;
  transform: scale(0.9);
  background: #009688;
  border-color: #009688;
  color: white;
  pointer-events: none;
}

.numberdash-btn.shake {
  animation: shake 0.4s cubic-bezier(.36, .07, .19, .97) both;
  background: #ff5d8f;
  border-color: #ff5d8f;
  color: white;
}

@keyframes shake {

  10%,
  90% {
    transform: translate3d(-1px, 0, 0);
  }

  20%,
  80% {
    transform: translate3d(2px, 0, 0);
  }

  30%,
  50%,
  70% {
    transform: translate3d(-4px, 0, 0);
  }

  40%,
  60% {
    transform: translate3d(4px, 0, 0);
  }
}

/* Prevent body scroll when any game is fullscreen */
body.has-fullscreen-overlay {
  overflow: hidden;
}

/* Snake Game */
#snake-canvas {
  touch-action: none;
  border: 2px solid var(--border-light);
  border-radius: 12px;
  background: var(--bg-card);
  /* Prevent scroll on mobile while swiping */
}



/* When card is fullscreen */
.card.is-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9999;
  width: 100vw;
  height: 100vh;
  margin: 0;
  border-radius: 0;
  border: none;
  background: #0f172a;
  /* Force dark bg */
  padding: 5rem 1rem 2rem 1rem;
  /* Add ample top padding for fixed button */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  /* Fix cutoff: align top */
  overflow-y: auto;
  overflow-x: hidden;
}

/* Ensure button stays fixed in corner when scrolling */
.card.is-fullscreen .btn-fullscreen {
  position: fixed !important;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 10001;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.card.is-fullscreen .btn-fullscreen:hover {
  background: var(--accent);
  color: #000;
  border-color: transparent;
}

[data-theme="light"] .card.is-fullscreen {
  background: #f8fafc;
}

.card.is-fullscreen .canvas-wrapper {
  max-height: 90vh !important;
  max-width: 95vw !important;
  width: 100% !important;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Adjust header in fullscreen */
.card.is-fullscreen .game-header {
  width: 100%;
  max-width: 1200px;
  margin-bottom: 0.5rem;
}

.card.is-fullscreen .cog-plot {
  display: none;
}

/* Number Dash Fullscreen Fixes */
.card.is-fullscreen .numberdash-grid {
  width: 100%;
  max-width: 80vh;
  /* Scale with height mostly to keep it centered and visible */
  gap: 2vh;
  grid-template-columns: repeat(auto-fill, minmax(12vh, 1fr));
  /* Larger buttons */
}

.card.is-fullscreen .numberdash-btn {
  font-size: 4vh;
  /* Scale text */
}

/* Guess Word Fullscreen Fixes */
.card.is-fullscreen #guessword-keyboard {
  width: 100%;
  max-width: 900px;
  display: flex !important;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
}

.card.is-fullscreen .guessword-key {
  width: 60px;
  height: 60px;
  font-size: 1.5rem;
}

.card.is-fullscreen #guessword-word {
  font-size: 4rem;
  margin-bottom: 2rem;
}

/* Upload Area Styles */
.upload-area {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(0, 0, 0, 0.6);
  padding: 0.5rem 1rem;
  border-radius: 50px;
  backdrop-filter: blur(4px);
  z-index: 10;
  transition: opacity 0.2s;
}

.upload-area:hover {
  background: rgba(0, 0, 0, 0.8);
}

.upload-area p {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.9rem;
  margin: 0;
  white-space: nowrap;
}

#sketch-upload-btn {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  min-width: auto;
}

/* Snake Touch Controls */
.snake-controls-area {
  position: relative;
  min-height: 300px;
  /* Reserve space for D-pad to prevent jumping */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.snake-controls-dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  /* margin-top: 1.5rem; Removed logic margin, handled by container centering */
  user-select: none;
  touch-action: manipulation;
  display: none;
  /* Hidden by default */
  position: absolute;
  /* Overlay or take same space */
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.snake-controls-dpad.active {
  display: flex !important;
}

.sequence-controls {
  /* Ensure start button is also centered */
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
}

.dpad-middle {
  display: flex;
  gap: 6rem;
  /* Increased gap from 4rem */
}

.dpad-btn {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  /* Consistent rounded rect instead of circle */
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-size: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.1s ease;
  padding: 0;
  line-height: 1;
  backdrop-filter: blur(4px);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .dpad-btn {
  border-color: rgba(0, 0, 0, 0.1);
  background: rgba(255, 255, 255, 0.6);
  color: #000;
}

.dpad-btn:active {
  background: var(--accent);
  color: #000;
  transform: scale(0.95);
  border-color: transparent;
}

/* Pause Overlay */
.snake-pause-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  display: flex;
  gap: 0.5rem;
  pointer-events: auto;
}

.snake-pause-overlay button {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  width: 48px !important;
  /* Slightly larger */
  height: 48px !important;
  min-width: 48px !important;
  border-radius: 50% !important;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
  flex-shrink: 0;
  overflow: hidden;
  /* Ensure content doesn't break shape */
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .snake-pause-overlay button {
  background: rgba(255, 255, 255, 0.8);
  border-color: rgba(0, 0, 0, 0.1);
  color: #000;
}

#snake-score-container {
  display: flex !important;
  justify-content: center;
  align-items: center;
  font-size: 1.5rem;
  /* Larger font size */
  font-weight: bold;
  gap: 4rem !important;
  /* Distinct separation */
}

#snake-score,
#snake-best {
  font-size: 2rem;
  /* Even larger for the numbers */
  color: var(--accent);
}

.snake-pause-overlay button:hover {
  background: var(--accent);
  color: #000;
  transform: scale(1.1);
  border-color: transparent;
}

/* Hide D-pad on desktop if desired, or keep for accessibility */
@media (min-width: 1025px) {
  /* Optional: hide if keyboard is primary. But user requested 'add arrow buttons', implying always visible. */
  /* .snake-controls-dpad { display: none; } */
}