:root {
  color-scheme: light;
  --deep: #003b76;
  --sea: #007fc7;
  --aqua: #2ee6ef;
  --foam: #f4feff;
  --ink: #06213d;
  --muted: #42657b;
  --line: rgba(0, 79, 143, 0.22);
  --gold: #ffd54f;
  --sun: #ffb02e;
  --coral: #ff566d;
  --pink: #ff7fc8;
  --panel: rgba(244, 254, 255, 0.93);
  --glass: rgba(255, 255, 255, 0.72);
  --shadow: 0 18px 42px rgba(0, 42, 92, 0.28);
  --radius: 8px;
  font-family:
    "Inter",
    "Noto Sans JP",
    "Yu Gothic UI",
    "Hiragino Sans",
    system-ui,
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.58), rgba(255, 255, 255, 0.05) 31%, rgba(0, 42, 92, 0.16)),
    url("./assets/ocean-board.svg") center top / cover fixed,
    #007fc7;
  color: var(--ink);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.2) 0 2px, transparent 2px 96px),
    linear-gradient(180deg, rgba(0, 28, 70, 0), rgba(0, 22, 58, 0.16));
  content: "";
  pointer-events: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.app-shell {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 34px;
}

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding: 18px 18px 20px;
  overflow: hidden;
  border: 3px solid rgba(255, 255, 255, 0.72);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(102, 231, 241, 0.54)),
    linear-gradient(90deg, rgba(255, 213, 79, 0.55), rgba(255, 86, 109, 0.28), rgba(46, 230, 239, 0.42));
  box-shadow:
    inset 0 0 0 2px rgba(0, 59, 118, 0.16),
    0 12px 0 rgba(0, 80, 145, 0.34),
    var(--shadow);
}

.topbar::before,
.draw-panel::before {
  position: absolute;
  right: 12px;
  left: 12px;
  height: 12px;
  border-radius: 6px;
  background: repeating-linear-gradient(
    90deg,
    #fff7bc 0 18px,
    #ff7fc8 18px 36px,
    #2ee6ef 36px 54px,
    #ffd54f 54px 72px
  );
  box-shadow: 0 0 18px rgba(255, 213, 79, 0.72);
  content: "";
}

.topbar::before {
  top: 0;
}

.eyebrow,
.section-kicker {
  margin: 0 0 4px;
  color: #005a9e;
  font-size: 0.74rem;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: #fffef3;
  font-size: clamp(2.25rem, 6vw, 4.85rem);
  font-weight: 950;
  line-height: 0.95;
  text-shadow:
    0 3px 0 #005a9e,
    0 6px 0 #003b76,
    0 11px 22px rgba(0, 38, 80, 0.34);
  -webkit-text-stroke: 1px rgba(0, 59, 118, 0.32);
}

h2 {
  color: #003b76;
  font-size: 1.16rem;
  font-weight: 950;
  line-height: 1.2;
}

.topbar-actions,
.draw-actions,
.panel-footer,
.inline-fields,
.draw-toolbar,
.panel-header,
.option-row,
.count-strip {
  display: flex;
  align-items: center;
}

.topbar-actions,
.draw-actions {
  gap: 8px;
}

.save-state {
  min-width: 5.7rem;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.64);
  border-radius: var(--radius);
  background: rgba(0, 59, 118, 0.64);
  color: #ffffff;
  font-size: 0.84rem;
  font-weight: 850;
  text-align: center;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(260px, 0.82fr) minmax(280px, 1fr) minmax(330px, 1.18fr);
  gap: 18px;
  align-items: stretch;
}

.control-panel,
.draw-panel {
  position: relative;
  display: flex;
  min-height: 620px;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  overflow: hidden;
  border: 3px solid rgba(255, 255, 255, 0.78);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(230, 252, 255, 0.88)),
    var(--panel);
  box-shadow:
    inset 0 0 0 2px rgba(0, 127, 199, 0.16),
    0 12px 0 rgba(0, 72, 132, 0.22),
    var(--shadow);
}

.control-panel::after,
.draw-panel::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 9px;
  background: linear-gradient(90deg, var(--coral), var(--gold), var(--aqua), var(--pink));
  content: "";
}

.draw-panel {
  border-color: rgba(255, 246, 166, 0.94);
  background:
    linear-gradient(180deg, rgba(255, 247, 188, 0.82), rgba(255, 255, 255, 0.2) 18%, rgba(225, 252, 255, 0.94) 38%),
    var(--panel);
}

.draw-panel::before {
  top: 0;
}

.panel-header,
.draw-toolbar {
  justify-content: space-between;
  gap: 12px;
}

.field {
  display: flex;
  min-width: 0;
  flex: 0 1 auto;
  flex-direction: column;
  gap: 7px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 950;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-width: 0;
  border: 2px solid rgba(0, 127, 199, 0.24);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(231, 252, 255, 0.94));
  color: var(--ink);
  outline: none;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.8);
}

.field input,
.field select {
  min-height: 44px;
  padding: 0 12px;
}

.field textarea {
  min-height: 280px;
  flex: 1;
  padding: 11px;
  resize: vertical;
  line-height: 1.55;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--coral);
  box-shadow:
    0 0 0 3px rgba(255, 86, 109, 0.2),
    inset 0 2px 0 rgba(255, 255, 255, 0.8);
}

.grow {
  flex: 1;
}

.inline-fields {
  gap: 10px;
}

.inline-fields .field {
  flex: 1;
}

.primary-button,
.ghost-button,
.icon-button,
.draw-button {
  min-height: 42px;
  border: 2px solid transparent;
  border-radius: var(--radius);
  font-weight: 950;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.58),
    0 4px 0 rgba(0, 52, 104, 0.24);
}

.primary-button {
  padding: 0 18px;
  border-color: rgba(255, 255, 255, 0.72);
  background: linear-gradient(180deg, #2ee6ef, #007fc7);
  color: #ffffff;
}

.ghost-button {
  padding: 0 14px;
  border-color: rgba(0, 127, 199, 0.2);
  background: linear-gradient(180deg, #ffffff, #dff9ff);
  color: var(--deep);
}

.ghost-button.danger {
  border-color: rgba(255, 86, 109, 0.36);
  color: #b11437;
}

.icon-button {
  display: inline-grid;
  width: 42px;
  min-width: 42px;
  place-items: center;
  border-color: rgba(255, 255, 255, 0.72);
  background: linear-gradient(180deg, #fff7bc, #ffb02e);
  color: #6d3300;
  font-size: 1.12rem;
}

.hidden {
  display: none;
}

[hidden] {
  display: none !important;
}

.panel-footer {
  justify-content: space-between;
  gap: 12px;
}

.meta-text {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 950;
}

.count-strip {
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.count-strip span {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  min-height: 30px;
  padding: 5px 9px;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fff7bc, #ffd54f);
  color: #724100;
  font-size: 0.78rem;
  font-weight: 950;
  box-shadow: 0 0 13px rgba(255, 213, 79, 0.42);
}

.count-strip strong {
  color: #003b76;
  font-size: 1.04rem;
}

.student-list {
  display: grid;
  max-height: 472px;
  gap: 8px;
  overflow: auto;
  padding-right: 4px;
}

.student-list::-webkit-scrollbar,
.field textarea::-webkit-scrollbar,
.result-list::-webkit-scrollbar {
  width: 10px;
}

.student-list::-webkit-scrollbar-thumb,
.field textarea::-webkit-scrollbar-thumb,
.result-list::-webkit-scrollbar-thumb {
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: var(--radius);
  background: #007fc7;
}

.student-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 46px;
  padding: 9px 10px;
  border: 2px solid rgba(0, 127, 199, 0.18);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(229, 251, 255, 0.9));
  box-shadow: 0 4px 0 rgba(0, 82, 145, 0.08);
}

.student-row.is-absent {
  border-color: rgba(255, 86, 109, 0.5);
  background: linear-gradient(180deg, #fff6fb, #ffe6eb);
  color: #77223a;
}

.student-name {
  min-width: 0;
  overflow: hidden;
  font-weight: 950;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.absence-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 950;
}

.absence-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--coral);
}

.option-row {
  gap: 10px;
  flex-wrap: wrap;
}

.check-option {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  gap: 8px;
  padding: 0 11px;
  border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fffdf0, #ddfbff);
  color: var(--deep);
  font-size: 0.84rem;
  font-weight: 950;
  box-shadow: 0 4px 0 rgba(0, 82, 145, 0.12);
}

.check-option input {
  width: 17px;
  height: 17px;
  accent-color: var(--sea);
}

.slot-machine {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  min-height: 128px;
  padding: 14px;
  border: 3px solid #003b76;
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(0, 30, 80, 0.9), rgba(0, 87, 154, 0.92)),
    var(--deep);
  box-shadow:
    inset 0 0 0 4px rgba(255, 213, 79, 0.84),
    inset 0 -18px 28px rgba(0, 16, 48, 0.28),
    0 8px 0 rgba(0, 47, 91, 0.32);
}

.slot-window {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 104px;
  place-items: center;
  overflow: hidden;
  border: 3px solid #fff7bc;
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(255, 254, 242, 0.92) 34%, rgba(170, 243, 255, 0.84) 66%, rgba(255, 255, 255, 0.96) 100%);
  color: var(--deep);
  font-size: clamp(1.05rem, 3vw, 1.58rem);
  font-weight: 950;
  text-align: center;
  box-shadow:
    inset 0 12px 18px rgba(255, 255, 255, 0.8),
    inset 0 -14px 22px rgba(0, 127, 199, 0.18),
    0 0 16px rgba(46, 230, 239, 0.46);
}

.slot-window::before,
.slot-window::after {
  position: absolute;
  right: 0;
  left: 0;
  height: 18px;
  background: rgba(0, 59, 118, 0.11);
  content: "";
  pointer-events: none;
}

.slot-window::before {
  top: 0;
}

.slot-window::after {
  bottom: 0;
}

.slot-window span {
  position: relative;
  z-index: 1;
  max-width: 100%;
  padding: 0 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.9);
  white-space: nowrap;
}

.slot-window.spinning span {
  animation: slotPulse 0.13s linear infinite;
}

.draw-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  min-height: 62px;
  padding: 0 18px;
  border-color: rgba(255, 255, 255, 0.86);
  background:
    linear-gradient(180deg, #ff7fc8 0%, #ff566d 50%, #c3153a 100%);
  color: #ffffff;
  font-size: 1.08rem;
  letter-spacing: 0;
  text-shadow: 0 2px 0 rgba(98, 0, 30, 0.42);
  box-shadow:
    inset 0 4px 0 rgba(255, 255, 255, 0.45),
    0 7px 0 #8f1030,
    0 0 20px rgba(255, 86, 109, 0.42);
}

.draw-button:active {
  transform: translateY(3px);
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.4),
    0 4px 0 #8f1030,
    0 0 16px rgba(255, 86, 109, 0.36);
}

.result-list {
  display: grid;
  gap: 10px;
  overflow: auto;
  padding-right: 2px;
}

.pair-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 2px solid rgba(255, 213, 79, 0.74);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(255, 247, 188, 0.96), rgba(255, 255, 255, 0.94) 28%, rgba(221, 251, 255, 0.94));
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.68),
    0 5px 0 rgba(0, 82, 145, 0.12);
}

.pair-number {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  background: linear-gradient(180deg, #fff7bc, #ffb02e);
  color: #623700;
  font-size: 0.9rem;
  font-weight: 950;
  box-shadow: 0 0 14px rgba(255, 213, 79, 0.55);
}

.pair-members {
  display: flex;
  min-width: 0;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.member-pill {
  max-width: 100%;
  min-height: 34px;
  padding: 6px 10px;
  overflow: hidden;
  border: 2px solid rgba(0, 127, 199, 0.18);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #f4feff, #bff7ff);
  color: var(--deep);
  font-weight: 950;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-pill.waiting {
  border-color: rgba(255, 86, 109, 0.3);
  background: linear-gradient(180deg, #fff6fb, #ffe0e8);
}

.empty-state {
  display: grid;
  min-height: 96px;
  place-items: center;
  border: 2px dashed rgba(0, 127, 199, 0.28);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.48);
  color: var(--muted);
  font-weight: 950;
}

.empty-list {
  display: grid;
  min-height: 128px;
  place-items: center;
  border: 2px dashed rgba(0, 127, 199, 0.28);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.48);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 950;
}

@keyframes slotPulse {
  from {
    transform: translateY(-24%);
    opacity: 0.5;
  }

  to {
    transform: translateY(24%);
    opacity: 1;
  }
}

@media (max-width: 980px) {
  body {
    background-attachment: scroll;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .control-panel,
  .draw-panel {
    min-height: 0;
  }

  .field textarea {
    min-height: 190px;
  }

  .student-list {
    max-height: 360px;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 10px;
  }

  .topbar {
    align-items: flex-start;
    padding-top: 22px;
  }

  .inline-fields {
    align-items: stretch;
    flex-direction: column;
  }

  .ghost-button.danger {
    width: 100%;
  }

  .slot-machine {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-height: 0;
  }

  .slot-window {
    min-height: 74px;
  }

  .draw-toolbar {
    align-items: flex-start;
  }
}
