:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-muted: #f6f8fc;
  --border: #d4dbe6;
  --text: #1c2533;
  --muted: #5a687c;
  --accent: #165dd6;
  --accent-soft: #e8f0ff;
  --success: #17844d;
  --danger: #ba2f2f;
  --shadow: 0 10px 24px rgba(18, 28, 44, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100dvh;
}

body {
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
  color: var(--text);
  background: linear-gradient(160deg, #edf3ff, #f8fafc 42%, #eef9f2);
}

.app-shell {
  max-width: 1320px;
  margin: 0 auto;
  padding:
    calc(10px + env(safe-area-inset-top))
    calc(12px + env(safe-area-inset-right))
    calc(12px + env(safe-area-inset-bottom))
    calc(12px + env(safe-area-inset-left));
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.brand h1 {
  margin: 0;
  font-size: clamp(1.2rem, 2vw, 1.8rem);
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
}

.tab-row,
.actions,
.icon-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  box-shadow: var(--shadow);
}

.stack {
  display: grid;
  gap: 10px;
}

.split {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

label {
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 10px;
  padding: 10px;
  font: inherit;
}

textarea {
  resize: vertical;
  min-height: 90px;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 9px 12px;
  font: inherit;
  cursor: pointer;
  font-weight: 700;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

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

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-secondary {
  background: var(--surface-muted);
  border-color: var(--border);
  color: #243246;
}

.btn-compact {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  font-size: 0.84rem;
  font-weight: 650;
  line-height: 1.2;
  border-radius: 9px;
  cursor: pointer;
}

.btn-soft {
  background: linear-gradient(180deg, #ffffff, #f3f8ff);
  border-color: #c4d4ee;
  color: #223c63;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.btn-danger {
  background: #ffeceb;
  border-color: #f5c1c1;
  color: #8b2525;
}

.btn-icon {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  background: var(--surface-muted);
  border-color: var(--border);
  color: #273446;
}

.btn-icon .ico {
  font-size: 1.05rem;
  line-height: 1;
}

.btn-icon.active {
  background: var(--accent-soft);
  border-color: #a8bff8;
  color: #184aa5;
}

.notice {
  border-radius: 10px;
  padding: 10px;
  font-weight: 600;
}

.notice.info {
  background: #ecf3ff;
  color: #1f4b8a;
}

.notice.error {
  background: #ffecec;
  color: #8a2121;
}

.notice.success {
  background: #e8f8ef;
  color: #206a44;
}

.muted {
  color: var(--muted);
}

.result-line {
  margin: 0;
  font-size: 0.94rem;
  color: #2f4058;
}

.result-wrong {
  color: #111111;
  font-weight: 800;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 11px;
  background: #fff;
  font-size: 0.9rem;
}

.pill strong {
  font-weight: 800;
}

.pill-score {
  border-color: #9bc1ff;
  background: #eaf3ff;
  color: #163f84;
}

.pill-penalty {
  border-color: #f4c8c8;
  background: #fff1f1;
  color: #8d2727;
}

.game-header {
  position: sticky;
  top: env(safe-area-inset-top);
  z-index: 5;
  background: #ffffffeb;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  backdrop-filter: blur(5px);
}

.hud-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-start;
  padding-bottom: 2px;
}

.timer-label {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: #3c4f6d;
}

.teacher-note {
  margin: 0;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #d7e6ff;
  background: #f4f8ff;
  color: #2d466e;
  font-size: 0.92rem;
}

.progress-wrap {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #e5ecf6;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: #39a96b;
  transition: width 200ms linear, background 200ms linear;
}

.placeholder-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(44px, 1fr));
  gap: 8px;
}

.placeholder-cell {
  min-height: 52px;
  border: 1px solid #cbd5e2;
  border-radius: 10px;
  background: #f8fbff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.25rem;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.placeholder-cell.active {
  border-width: 2px;
  border-color: var(--accent);
  background: #edf3ff;
  box-shadow: inset 0 0 0 1px #9bb8f3;
}

.placeholder-cell.filled {
  background: #fff;
}

.placeholder-cell.locked {
  opacity: 0.8;
}

.placeholder-cell.blink-green {
  animation: blinkGreen 0.3s linear 3;
}

.placeholder-cell.blink-red {
  animation: blinkRed 0.22s linear 6;
}

@keyframes blinkGreen {
  0%,
  100% {
    border-color: #58c184;
    box-shadow: 0 0 0 0 rgba(55, 186, 106, 0.4);
  }
  50% {
    border-color: #148548;
    box-shadow: 0 0 0 2px rgba(55, 186, 106, 0.25);
  }
}

@keyframes blinkRed {
  0%,
  100% {
    border-color: #e19595;
    transform: translateX(0);
  }
  25% {
    border-color: #d14343;
    transform: translateX(-1px);
  }
  75% {
    border-color: #d14343;
    transform: translateX(1px);
  }
}

.letter-bank {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(52px, 1fr));
  gap: 8px;
}

.letter-tile {
  min-height: 52px;
  border: 1px solid #aac2ea;
  border-radius: 10px;
  background: #eef4ff;
  color: #1a3e7f;
  font-size: 1.2rem;
  font-weight: 800;
}

.letter-tile.used {
  opacity: 0.24;
  pointer-events: none;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid #e2e7ef;
  padding: 8px 6px;
  vertical-align: top;
}

th {
  font-size: 0.86rem;
  color: #4d5f79;
}

.table-header-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  color: inherit;
  border-radius: 6px;
}

.table-header-btn:hover {
  color: #1e3f74;
}

.table-header-with-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sort-indicator {
  font-size: 0.75rem;
  color: #6f819d;
}

.table-filter-toggle {
  min-width: 28px;
  min-height: 28px;
  padding: 0 6px;
  border-radius: 8px;
  border: 1px solid #cbd6ea;
  background: #f7faff;
  color: #2a4a79;
  line-height: 1;
}

.table-filter-toggle.active {
  background: #e8f0ff;
  border-color: #9fb5dc;
}

.table-filter-row th {
  background: #f8fbff;
}

.table-filter-row select {
  padding: 6px 8px;
  font-size: 0.84rem;
}

.checkbox-cell {
  width: 34px;
}

.row-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.compact-actions {
  gap: 6px;
  align-items: center;
}

.assign-panel {
  border: 1px dashed #abc2ea;
  background: #f3f7ff;
  border-radius: 12px;
  padding: 10px;
}

.help-content h3 {
  margin-bottom: 6px;
}

.help-content ul {
  margin-top: 4px;
}

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

@media (min-width: 900px) {
  .split.admin {
    grid-template-columns: minmax(250px, 320px) minmax(0, 1.55fr);
    align-items: start;
  }
}

@media (max-width: 760px) {
  .hud-line {
    gap: 6px;
  }

  .placeholder-row {
    grid-template-columns: repeat(auto-fit, minmax(42px, 1fr));
  }
}
