:root {
  --ink: #27324a;
  --muted: #68708a;
  --cream: #fff8e8;
  --sky: #dff3ff;
  --mint: #dcf8e9;
  --peach: #ffe2cf;
  --pink: #ffe3ee;
  --yellow: #fff1ac;
  --purple: #eadfff;
  --blue: #d9ecff;
  --green: #dff6d5;
  --shadow: 0 12px 30px rgba(52, 67, 92, 0.14);
  --soft-shadow: 0 6px 16px rgba(52, 67, 92, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 226, 207, 0.75), transparent 28rem),
    linear-gradient(135deg, #fff8e8 0%, #e4f6ff 48%, #edfbe8 100%);
}

button,
input,
textarea {
  font: inherit;
}

.game-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.eyebrow {
  margin: 0 0 4px;
  color: #54627d;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1;
}

.score-card {
  flex: 0 0 auto;
  min-width: 150px;
  padding: 14px 18px;
  border: 3px solid rgba(255, 255, 255, 0.8);
  border-radius: 18px;
  background: #ffffff;
  box-shadow: var(--soft-shadow);
  font-size: 1.1rem;
  font-weight: 900;
  text-align: center;
}

.settings-open,
.settings-close {
  min-height: 46px;
  padding: 10px 16px;
  border: 0;
  border-radius: 999px;
  color: #21304b;
  background: #f7e3b1;
  box-shadow: var(--soft-shadow);
  font-weight: 900;
  cursor: pointer;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    filter 160ms ease;
}

.settings-open:hover,
.settings-close:hover {
  transform: translateY(-2px);
  filter: brightness(1.03);
  box-shadow: 0 10px 22px rgba(52, 67, 92, 0.18);
}

.question-panel {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--soft-shadow);
}

.question-badge {
  flex: 0 0 auto;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--yellow);
  color: #51440d;
  font-weight: 900;
}

.question-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
  font-weight: 700;
}

.play-area {
  padding: 18px;
  border: 3px solid rgba(255, 255, 255, 0.8);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: var(--shadow);
}

.zone-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 4px 10px;
}

.zone-heading h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
}

.zone-heading span {
  color: var(--muted);
  font-weight: 800;
}

.sentence-heading {
  margin-top: 22px;
}

.word-bank {
  position: relative;
  height: clamp(220px, 32vw, 330px);
  overflow: hidden;
  border: 4px solid rgba(255, 255, 255, 0.9);
  border-radius: 24px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.22) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.22) 1px, transparent 1px),
    linear-gradient(135deg, #fff3b8 0%, #dff3ff 55%, #dcf8e9 100%);
  background-size: 34px 34px, 34px 34px, auto;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35);
}

.sentence-area {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 14px;
  min-height: 185px;
  padding: 22px;
  border: 4px dashed #a8cae8;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.8);
}

.sentence-area:empty::after {
  content: "Drop the words here to build the sentence.";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  color: #8b95aa;
  font-size: clamp(1.05rem, 2.6vw, 1.45rem);
  font-weight: 800;
  text-align: center;
  pointer-events: none;
}

.word-card {
  min-width: 74px;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border: 3px solid rgba(255, 255, 255, 0.78);
  border-radius: 16px;
  color: #26324a;
  box-shadow: var(--soft-shadow);
  font-size: clamp(1rem, 1.8vw, 1.28rem);
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
  user-select: none;
  touch-action: none;
  cursor: grab;
  will-change: transform, left, top;
  transition:
    box-shadow 160ms ease,
    filter 160ms ease,
    scale 160ms ease;
}

.word-card:hover {
  filter: brightness(1.03);
  scale: 1.03;
}

.word-card.dragging {
  cursor: grabbing;
  filter: brightness(1.05);
  opacity: 0.96;
  scale: 1.06;
  box-shadow: 0 18px 34px rgba(52, 67, 92, 0.26);
  transition: none;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  margin: 22px 0 16px;
}

.btn {
  min-width: 150px;
  min-height: 52px;
  padding: 12px 20px;
  border: 0;
  border-radius: 999px;
  color: #21304b;
  box-shadow: var(--soft-shadow);
  font-size: 1.08rem;
  font-weight: 900;
  cursor: pointer;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    filter 160ms ease;
}

.btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.03);
  box-shadow: 0 10px 22px rgba(52, 67, 92, 0.18);
}

.btn:active {
  transform: translateY(1px);
}

.check {
  background: #b9f2c9;
}

.reset {
  background: #ffd7c4;
}

.next {
  background: #cde5ff;
}

.save {
  background: #b9f2c9;
}

.restore {
  background: #fff1ac;
}

.cancel {
  background: #eadfff;
}

.feedback {
  min-height: 52px;
  margin: 0 auto;
  padding: 13px 18px;
  border-radius: 18px;
  color: transparent;
  font-size: clamp(1.05rem, 2.2vw, 1.35rem);
  font-weight: 900;
  text-align: center;
  transform: translateY(4px);
}

.feedback.show {
  animation: feedback-pop 360ms ease both;
}

.feedback.correct {
  background: #dff8dc;
  color: #23733c;
}

.feedback.incorrect {
  background: #ffe3e0;
  color: #aa3d31;
}

.feedback.info {
  background: #e4f0ff;
  color: #315f9d;
}

.settings-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(39, 50, 74, 0.38);
}

.settings-backdrop[hidden] {
  display: none;
}

.settings-modal {
  width: min(780px, 100%);
  max-height: min(90vh, 760px);
  overflow: auto;
  padding: 24px;
  border: 4px solid rgba(255, 255, 255, 0.86);
  border-radius: 24px;
  background: #fffdf6;
  box-shadow: 0 24px 60px rgba(39, 50, 74, 0.28);
}

.settings-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.settings-header h2 {
  margin-bottom: 0;
  font-size: clamp(1.55rem, 3vw, 2.2rem);
}

.editor-label {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 900;
}

#sentenceEditor {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  padding: 16px;
  border: 3px solid #cde5ff;
  border-radius: 18px;
  color: var(--ink);
  background: #ffffff;
  box-shadow: inset 0 2px 8px rgba(52, 67, 92, 0.08);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.55;
}

#sentenceEditor:focus {
  border-color: #88bff5;
  outline: 4px solid rgba(205, 229, 255, 0.75);
}

.settings-help,
.settings-message {
  margin: 10px 0 0;
  color: var(--muted);
  font-weight: 800;
}

.settings-message {
  min-height: 24px;
}

.settings-message.error {
  color: #aa3d31;
}

.settings-message.success {
  color: #23733c;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 18px;
}

@keyframes feedback-pop {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 720px) {
  .game-shell {
    width: min(100% - 20px, 1120px);
    padding-top: 18px;
  }

  .game-header,
  .question-panel,
  .zone-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .score-card {
    width: 100%;
  }

  .settings-open {
    width: 100%;
  }

  .play-area {
    padding: 12px;
    border-radius: 20px;
  }

  .word-bank {
    height: 260px;
    border-radius: 20px;
  }

  .sentence-area {
    min-height: 210px;
    gap: 10px;
    padding: 16px;
    border-radius: 20px;
  }

  .word-card {
    min-width: 66px;
    min-height: 44px;
    padding: 9px 12px;
    border-radius: 14px;
  }

  .btn {
    flex: 1 1 170px;
  }

  .settings-backdrop {
    align-items: start;
    padding: 12px;
  }

  .settings-modal {
    padding: 16px;
    border-radius: 20px;
  }

  .settings-header,
  .settings-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .settings-close {
    width: 100%;
  }
}
