* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  color-scheme: dark;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
}

body {
  min-height: 100vh;
  background: radial-gradient(circle at top, #151a2b, #0f1320 55%, #0b0f18);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.5rem;
  color: #e6e9f2;
  overflow-x: hidden;
  min-width: 0;
}

.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 0 24px;
  z-index: 1000;
}

.top-bar-logo {
  height: 32px;
  width: auto;
}

.home-screen {
  width: min(600px, 100%);
  background: rgba(18, 22, 36, 0.9);
  backdrop-filter: blur(12px);
  border-radius: 24px;
  padding: 3rem 2.5rem;
  box-shadow: 0 30px 60px rgba(5, 8, 15, 0.6);
  text-align: center;
}

.home-screen h1 {
  font-size: clamp(2rem, 3vw + 1.2rem, 3rem);
  margin-bottom: 1rem;
  color: #f2f4ff;
}

.home-screen p {
  font-size: 1.1rem;
  color: #b6bdd4;
  margin-bottom: 2rem;
}

.group-buttons {
  display: grid;
  gap: 1rem;
  max-width: 400px;
  margin: 0 auto;
  width: 100%;
}

.group-btn {
  border: none;
  border-radius: 999px;
  padding: 1.2rem 2rem;
  font-size: 1.1rem;
  font-weight: 600;
  background: #5c7cfa;
  color: #fff;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.group-btn:hover {
  background: #4c6ef5;
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(76, 110, 245, 0.4);
}

.group-btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.app {
  width: min(900px, 100%);
  max-width: 100%;
  background: rgba(15, 18, 30, 0.92);
  backdrop-filter: blur(12px);
  border-radius: 24px;
  padding: 2.5rem;
  box-shadow: 0 30px 60px rgba(5, 8, 15, 0.6);
  display: grid;
  gap: 2rem;
  overflow-x: hidden;
  min-width: 0;
}

.move-history {
  display: grid;
  gap: 0.75rem;
  background: #1a1f33;
  border: 1px solid #2b3450;
  border-radius: 18px;
  padding: 1.25rem 1.5rem;
  text-align: center;
}

.move-history h2 {
  font-size: 1.1rem;
  color: #dfe6ff;
}

.history-list {
  display: grid;
  gap: 0.4rem;
  list-style: none;
  padding-left: 0;
  color: #b8c0da;
  font-size: 1.5rem;
  /* height to fit 5 items: 5 * font-size + 4 * gap */
  height: calc(5 * 1.5rem + 4 * 0.4rem);
  overflow-y: auto;
}

.header h1 {
  font-size: clamp(1.8rem, 2vw + 1.2rem, 2.6rem);
  margin-bottom: 0.4rem;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.theme-toggle {
  background: #1f2a44;
  color: #e6e9f2;
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
}

.theme-toggle:hover {
  background: #2b3552;
}

.instructions {
  margin-top: 0.75rem;
}

.instructions summary {
  cursor: pointer;
  font-weight: 600;
  color: #91a7ff;
  font-size: 1rem;
  list-style: none;
  user-select: none;
  padding: 0.5rem 0;
}

.instructions summary::-webkit-details-marker {
  display: none;
}

.instructions summary::before {
  content: "▶ ";
  display: inline-block;
  transition: transform 0.2s ease;
}

.instructions[open] summary::before {
  transform: rotate(90deg);
}

.instructions summary:hover {
  color: #748ffc;
}

.instructions-content {
  margin-top: 0.75rem;
  padding-left: 1.2rem;
}

.instructions-content h3 {
  margin-bottom: 0.5rem;
  color: #dfe6ff;
}

.instructions-content ul {
  list-style-type: disc;
  margin-left: 1.2rem;
}

.instructions-content li {
  color: #b8c0da;
  font-size: 1rem;
  margin-bottom: 0.4rem;
}

.instructions-content p {
  color: #b8c0da;
  font-size: 1rem;
  margin-bottom: 0.4rem;
}

.header p {
  color: #b8c0da;
  font-size: 1rem;
}

.register {
  display: grid;
  grid-template-columns: repeat(10, minmax(48px, 1fr));
  gap: 0.75rem;
  max-width: 100%;
}

.status {
  min-height: 1.5rem;
  font-weight: 600;
  color: #dfe6ff;
}

.solution {
  min-height: 1.5rem;
  font-size: 0.95rem;
  color: #b8c0da;
}

.slot {
  background: #1c2337;
  border: 2px solid #2d3856;
  border-radius: 16px;
  height: 78px;
  display: grid;
  place-items: center;
  font-size: 1.8rem;
  font-weight: 700;
  color: #dfe6ff;
  transition: transform 0.2s ease, background 0.2s ease;
}

.slot-first-half {
  border: 3px solid #1e40af;
}

.slot-second-half {
  border: 3px solid #ff8c00;
}

.slot[data-value="1"] {
  background: #4c6ef5;
  color: #fff;
  transform: translateY(-4px);
}

.slot-first-half[data-value="1"] {
  border-color: #1e40af;
}

.slot-second-half[data-value="1"] {
  border-color: #ff8c00;
}

.controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.8rem;
  max-width: 100%;
}

.answer-form {
  display: grid;
  gap: 0.6rem;
  justify-items: center;
  text-align: center;
  max-width: 100%;
}

.word-form {
  display: grid;
  gap: 0.6rem;
  justify-items: center;
  text-align: center;
  max-width: 100%;
}

.hidden {
  display: none !important;
}

.answer-form label {
  font-weight: 600;
  color: #dfe6ff;
}

.answer-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: center;
}

.answer-row input {
  width: min(260px, 80vw);
  padding: 0.75rem 1rem;
  border-radius: 999px;
  border: 2px solid #2d3856;
  font-size: 1rem;
  outline: none;
  background: #121826;
  color: #e6e9f2;
}

.thor-logo {
  display: flex;
  justify-content: center;
  margin-top: 1rem;
}

.thor-logo img {
  width: min(160px, 60vw);
  height: auto;
}

.answer-row input:focus {
  border-color: #5c7cfa;
  box-shadow: 0 0 0 3px rgba(92, 124, 250, 0.3);
}

.answer-status {
  min-width: 1.4rem;
  font-size: 1.4rem;
  font-weight: 700;
}

.answer-status.correct {
  color: #2f9e44;
}

.answer-status.wrong {
  color: #e03131;
}

.answer-form.shake {
  animation: shake 0.35s ease-in-out;
}

.answer-details {
  text-align: left;
  color: #dfe6ff;
  font-weight: 600;
  margin-top: 0.5rem;
}

.answer-details-title {
  font-size: 1.25rem;
  margin: 0 0 0.4rem 0;
  color: #f1f5ff;
}

.answer-details-list {
  margin: 0 0 0 1rem;
  padding: 0;
  list-style: disc;
  color: #dfe6ff;
}

.answer-table {
  margin-top: 1rem;
  display: flex;
  justify-content: center;
  max-width: 100%;
  overflow-x: auto;
}

.answer-table table {
  border-collapse: collapse;
  background: #121826;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(5, 8, 15, 0.5);
}

.answer-table th,
.answer-table td {
  border: 1px solid #2d3856;
  padding: 0.4rem 0.6rem;
  min-width: 32px;
  text-align: center;
  font-size: 0.9rem;
  color: #dfe6ff;
}

.answer-table th {
  background: #1c2337;
  font-weight: 700;
}

@keyframes shake {
  0% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-4px); }
  100% { transform: translateX(0); }
}

button {
  border: none;
  border-radius: 999px;
  padding: 0.9rem 1.2rem;
  font-size: 0.95rem;
  font-weight: 600;
  background: #2b3245;
  color: #f2f4ff;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(5, 8, 15, 0.6);
}

button:active {
  transform: translateY(0);
  box-shadow: none;
}

#reset {
  background: #e03131;
}

#reset:hover {
  background: #c92a2a;
}

#check-all {
  background: #7048e8;
}

#check-all:hover {
  background: #5f3dc4;
}

.all-solutions {
  min-height: 1rem;
  padding: 1rem;
  background: #1a1f33;
  border: 1px solid #2b3450;
  border-radius: 18px;
  color: #dfe6ff;
  font-size: 0.9rem;
}

.all-solutions h3 {
  margin-bottom: 0.75rem;
  color: #dfe6ff;
}

.all-solutions .solutions-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.all-solutions .solution-item {
  background: #4c6ef5;
  color: #fff;
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  font-weight: 600;
}

@media (max-width: 720px) {
  body {
    padding: 1.5rem 1rem;
  }

  .home-screen {
    padding: 2rem 1.5rem;
  }

  .app {
    padding: 1.5rem;
  }

  .register {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .slot {
    height: 64px;
  }
}

body.light {
  background: radial-gradient(circle at top, #f7f9ff, #e2e7ff 55%, #c9d2ff);
  color: #1a1e2a;
}

body.light .home-screen,
body.light .app {
  background: #ffffffcc;
  box-shadow: 0 30px 60px rgba(31, 38, 135, 0.2);
}

body.light .home-screen h1 {
  color: #1a1e2a;
}

body.light .home-screen p,
body.light .history-list,
body.light .instructions-content li,
body.light .instructions-content p,
body.light .header p,
body.light .answer-form label,
body.light .word-form label,
body.light .solution {
  color: #4d5670;
}

body.light .move-history,
body.light .all-solutions {
  background: #f8f9ff;
  border-color: #e1e6ff;
  color: #2d3658;
}

body.light .move-history h2,
body.light .instructions-content h3,
body.light .status,
body.light .answer-details {
  color: #2d3658;
}

body.light .instructions summary {
  color: #4361ee;
}

body.light .instructions summary:hover {
  color: #2b47d6;
}

body.light .slot {
  background: #f4f6ff;
  border-color: #d6ddff;
  color: #2d3658;
}

body.light .slot-first-half {
  border: 3px solid #1e40af;
}

body.light .slot-second-half {
  border: 3px solid #ff8c00;
}

body.light .slot[data-value="1"] {
  background: #4361ee;
  color: #fff;
}

body.light .slot-first-half[data-value="1"] {
  border-color: #1e40af;
}

body.light .slot-second-half[data-value="1"] {
  border-color: #ff8c00;
}

body.light .answer-row input {
  background: #fff;
  border-color: #d6ddff;
  color: #1a1e2a;
}

body.light .answer-row input:focus {
  border-color: #4361ee;
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
}

body.light .answer-table table {
  background: #fff;
  box-shadow: 0 10px 24px rgba(26, 30, 42, 0.08);
}

body.light .answer-table th,
body.light .answer-table td {
  border-color: #e1e6ff;
  color: #2d3658;
}

body.light .answer-table th {
  background: #f4f6ff;
}

body.light button {
  background: #1a1e2a;
  color: #fff;
}

body.light button:hover {
  box-shadow: 0 10px 24px rgba(26, 30, 42, 0.2);
}

body.light #reset {
  background: #f0544f;
}

body.light #reset:hover {
  background: #d6453f;
}

body.light #check-all {
  background: #7950f2;
}

body.light #check-all:hover {
  background: #6741d9;
}

body.light .all-solutions h3 {
  color: #2d3658;
}

body.light .all-solutions .solution-item {
  background: #4361ee;
}

@media (max-width: 420px) {
  .controls {
    grid-template-columns: 1fr;
  }

  .answer-row input {
    width: 100%;
  }
}
