:root {
  color-scheme: light;
  font-family: "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  font-synthesis: none;
  --ink: #263b50;
  --ink-strong: #172a3a;
  --ink-soft: #536779;
  --coral: #df6758;
  --coral-strong: #b9473d;
  --coral-soft: #fde7e2;
  --sky: #70b4d5;
  --sky-strong: #236c91;
  --sky-soft: #e3f3fa;
  --cream: #f6f0e5;
  --paper: #fffdf8;
  --surface: #ffffff;
  --surface-soft: #f5f8fa;
  --line: #cad6de;
  --line-strong: #aabcc8;
  --success: #27704d;
  --success-soft: #e0f3e8;
  --warning: #815d14;
  --warning-soft: #fff1c9;
  --danger: #a63232;
  --danger-soft: #fde7e5;
  --focus: #6d42d8;
  --shadow: 0 15px 40px rgb(38 59 80 / 10%);
  --radius-lg: 24px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--cream);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 9% 2%, rgb(223 103 88 / 16%), transparent 25rem),
    radial-gradient(circle at 95% 12%, rgb(112 180 213 / 22%), transparent 27rem),
    linear-gradient(180deg, #fffdf8 0, var(--cream) 46rem);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgb(38 59 80 / 4%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(38 59 80 / 4%) 1px, transparent 1px);
  background-size: 32px 32px;
  content: "";
  mask-image: linear-gradient(to bottom, #000, transparent 55rem);
  pointer-events: none;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input {
  min-height: 48px;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: .58;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 3px;
}

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

h1,
h2,
h3,
strong {
  overflow-wrap: anywhere;
}

h1 {
  font-size: clamp(2rem, 8vw, 3.8rem);
  line-height: 1.12;
  letter-spacing: -.045em;
}

h2 {
  margin-bottom: .7rem;
  font-size: clamp(1.45rem, 5vw, 2.05rem);
  line-height: 1.25;
}

h3 {
  margin-bottom: .55rem;
  font-size: 1.08rem;
  line-height: 1.35;
}

p,
li,
label,
input,
select,
button {
  line-height: 1.55;
}

[hidden] {
  display: none !important;
}

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

.skip-link {
  position: fixed;
  top: .5rem;
  left: .5rem;
  z-index: 100;
  border-radius: 10px;
  padding: .7rem 1rem;
  color: #fff;
  background: var(--ink-strong);
  font-weight: 850;
  text-decoration: none;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: none;
}

.site-header {
  width: min(100% - 1.5rem, 1180px);
  min-height: 80px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: .7rem;
  color: var(--ink-strong);
  text-decoration: none;
}

.brand-mark {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 15px 15px 15px 5px;
  color: #fff;
  background:
    linear-gradient(145deg, var(--coral), #f39a79 48%, var(--sky));
  box-shadow: 0 8px 22px rgb(223 103 88 / 24%);
  font-size: .78rem;
  font-weight: 950;
  letter-spacing: -.04em;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 1rem;
}

.brand small {
  margin-top: .05rem;
  color: var(--ink-soft);
  font-size: .68rem;
}

.connection-badge {
  flex: 0 0 auto;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: .4rem .75rem;
  color: var(--ink-soft);
  background: rgb(255 255 255 / 82%);
  font-size: .72rem;
  font-weight: 850;
}

.connection-badge::before {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c39a38;
  content: "";
}

.connection-badge.online {
  border-color: #86bea0;
  color: var(--success);
  background: var(--success-soft);
}

.connection-badge.online::before {
  background: var(--success);
}

.connection-badge.offline {
  border-color: #e0aaa6;
  color: var(--danger);
  background: var(--danger-soft);
}

.connection-badge.offline::before {
  background: var(--danger);
}

main {
  width: min(100% - 1rem, 1180px);
  margin: 0 auto;
  padding-bottom: 3rem;
}

.landing-view {
  display: grid;
  gap: 1rem;
  align-items: start;
  margin-top: 1rem;
}

.card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: clamp(1rem, 4vw, 1.5rem);
  background: rgb(255 255 255 / 94%);
  box-shadow: var(--shadow);
}

.welcome-card {
  position: relative;
  overflow: hidden;
  min-height: 610px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(1.4rem, 5vw, 2.8rem);
  background:
    linear-gradient(155deg, rgb(255 255 255 / 98%), rgb(251 248 241 / 96%));
}

.welcome-card::after {
  position: absolute;
  right: -5rem;
  bottom: -5rem;
  width: 15rem;
  height: 15rem;
  border: 24px solid rgb(112 180 213 / 17%);
  border-radius: 50%;
  content: "";
  pointer-events: none;
}

.eyebrow {
  margin-bottom: .35rem;
  color: var(--coral-strong);
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .04em;
}

.welcome-card h1 {
  margin-bottom: 1.1rem;
  color: var(--ink-strong);
}

.welcome-card h1 span {
  color: var(--coral-strong);
}

.welcome-lead {
  max-width: 34rem;
  margin-bottom: 1.25rem;
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1.75;
  word-break: keep-all;
}

.feature-list,
.learning-notice ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.feature-list {
  display: grid;
  gap: .65rem;
}

.feature-list li {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: .1rem .75rem;
  align-items: center;
}

.feature-list li > span {
  grid-row: 1 / 3;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: var(--ink-strong);
  background: var(--sky-soft);
  font-size: 1.15rem;
  font-weight: 900;
}

.feature-list strong {
  font-size: .9rem;
}

.feature-list small {
  color: var(--ink-soft);
  font-size: .72rem;
}

.learning-notice {
  position: relative;
  z-index: 1;
  margin-top: 1.4rem;
  border: 1px solid #e0b1aa;
  border-radius: 17px;
  padding: 1rem;
  background: var(--coral-soft);
}

.learning-notice li {
  position: relative;
  padding-left: 1rem;
  color: #5d423f;
  font-size: .76rem;
  line-height: 1.65;
}

.learning-notice li::before {
  position: absolute;
  left: .1rem;
  color: var(--coral-strong);
  content: "•";
  font-weight: 900;
}

.learning-notice.in-game {
  margin-top: 0;
  background: #fff8f5;
}

.health-status {
  position: relative;
  z-index: 1;
  margin: 1rem 0 0;
  color: var(--ink-soft);
  font-size: .75rem;
  font-weight: 750;
}

.health-status.ok {
  color: var(--success);
}

.health-status.error {
  color: var(--danger);
}

.entry-card {
  overflow: hidden;
  padding: 0;
}

.role-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .35rem;
  border-bottom: 1px solid var(--line);
  padding: .55rem;
  background: #edf3f6;
}

.role-tab {
  min-height: 52px;
  border: 1px solid transparent;
  border-radius: 13px;
  color: var(--ink-soft);
  background: transparent;
  font-weight: 900;
}

.role-tab:hover {
  background: rgb(255 255 255 / 74%);
}

.role-tab.active {
  border-color: var(--line);
  color: var(--ink-strong);
  background: #fff;
  box-shadow: 0 4px 14px rgb(38 59 80 / 8%);
}

.entry-panel {
  padding: clamp(1.15rem, 5vw, 2rem);
}

.section-title,
.card-heading,
.screen-heading,
.teacher-heading,
.session-toolbar,
.player-identity {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.section-title {
  justify-content: flex-start;
  margin-bottom: 1rem;
}

.section-title h2,
.card-heading h2,
.card-heading h3,
.screen-heading h2,
.teacher-heading h2,
.session-toolbar h1,
.player-identity h2 {
  margin-bottom: 0;
}

.section-icon {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 16px;
  font-size: 1.5rem;
}

.section-icon.coral {
  background: var(--coral-soft);
}

.section-icon.sky {
  background: var(--sky-soft);
}

form {
  display: grid;
  gap: .5rem;
}

label {
  color: var(--ink-strong);
  font-size: .88rem;
  font-weight: 850;
}

input,
select {
  width: 100%;
  border: 1.5px solid var(--line-strong);
  border-radius: 12px;
  padding: .7rem .82rem;
  color: var(--ink-strong);
  background: #fff;
}

input::placeholder {
  color: #81909b;
}

#joinRoomCode {
  text-transform: uppercase;
  letter-spacing: .12em;
  font-weight: 900;
}

.field-help {
  margin: -.15rem 0 .35rem;
  color: var(--ink-soft);
  font-size: .75rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .65rem;
}

.form-row > div {
  display: grid;
  gap: .4rem;
}

.check-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .7rem;
  align-items: start;
  min-height: 66px;
  margin: .5rem 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: .75rem;
  background: var(--surface-soft);
}

.check-row input {
  width: 22px;
  min-height: 22px;
  margin: .1rem 0 0;
}

.check-row strong,
.check-row small {
  display: block;
}

.check-row small {
  margin-top: .1rem;
  color: var(--ink-soft);
  font-size: .72rem;
  font-weight: 500;
}

.password-details {
  margin: .5rem 0;
  border-top: 1px solid var(--line);
  padding-top: .75rem;
}

.password-details summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  color: var(--ink-soft);
  font-size: .8rem;
  font-weight: 800;
  cursor: pointer;
}

.password-details[open] {
  display: grid;
  gap: .45rem;
}

.button {
  min-height: 48px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: .65rem 1rem;
  font-weight: 900;
}

.button.primary {
  color: #fff;
  background: var(--ink);
}

.button.primary:hover:not(:disabled) {
  background: var(--ink-strong);
}

.button.secondary {
  border-color: var(--line-strong);
  color: var(--ink-strong);
  background: #fff;
}

.button.secondary:hover:not(:disabled) {
  border-color: var(--sky-strong);
  background: var(--sky-soft);
}

.button.warning {
  border-color: #d8bd77;
  color: var(--warning);
  background: var(--warning-soft);
}

.button.danger {
  border-color: #ddaaa7;
  color: var(--danger);
  background: var(--danger-soft);
}

.button.wide {
  width: 100%;
}

.button.compact {
  min-height: 40px;
  padding: .45rem .7rem;
  font-size: .75rem;
}

.text-button {
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  padding: .45rem .65rem;
  color: var(--ink-soft);
  background: transparent;
  font-weight: 800;
}

.text-button:hover {
  background: var(--surface-soft);
}

.form-message {
  min-height: 1.3rem;
  margin: 0;
  color: var(--ink-soft);
  font-size: .76rem;
  font-weight: 750;
}

.form-message.error {
  color: var(--danger);
}

.form-message.success {
  color: var(--success);
}

.session-view {
  padding-bottom: 1rem;
}

.session-toolbar {
  min-height: 76px;
  border-bottom: 1px solid var(--line);
}

.session-toolbar h1 {
  font-size: clamp(1.35rem, 4vw, 2rem);
}

.session-toolbar-actions {
  display: flex;
  align-items: center;
  gap: .45rem;
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid #e1a59e;
  border-radius: 999px;
  padding: .35rem .65rem;
  color: var(--coral-strong);
  background: var(--coral-soft);
  font-size: .7rem;
  font-weight: 900;
}

.round-bar {
  position: sticky;
  top: .5rem;
  z-index: 25;
  min-height: 72px;
  margin: .5rem 0 1rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: .8rem;
  align-items: center;
  border: 1px solid #9cabb5;
  border-radius: 18px;
  padding: .75rem 1rem;
  color: #fff;
  background: rgb(38 59 80 / 96%);
  box-shadow: 0 9px 25px rgb(38 59 80 / 21%);
  backdrop-filter: blur(12px);
}

.round-bar span,
.round-bar small {
  display: block;
  color: #d9e4eb;
  font-size: .69rem;
  font-weight: 750;
}

.round-bar strong {
  display: block;
  margin-top: .1rem;
  font-size: .95rem;
}

.round-bar-center {
  min-width: 132px;
  border-right: 1px solid rgb(255 255 255 / 22%);
  border-left: 1px solid rgb(255 255 255 / 22%);
  padding-inline: 1rem;
  text-align: center;
}

.round-bar-center span {
  color: #fff;
  font-size: .78rem;
}

.round-bar time {
  min-width: 70px;
  font-size: 1.35rem;
  font-weight: 950;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.teacher-view,
.teacher-main,
.teacher-side {
  display: grid;
  gap: 1rem;
}

.teacher-heading {
  align-items: flex-start;
  background:
    linear-gradient(135deg, #fff, var(--sky-soft));
}

.teacher-heading p {
  margin-bottom: 0;
  color: var(--ink-soft);
  font-size: .78rem;
}

.room-code-line {
  display: flex;
  align-items: center;
  gap: .7rem;
}

.room-code-line > strong {
  color: var(--ink-strong);
  font-size: clamp(2rem, 8vw, 3rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: .12em;
}

.teacher-summary {
  min-width: 100px;
  border-radius: 16px;
  padding: .7rem;
  background: #fff;
  text-align: center;
}

.teacher-summary span,
.teacher-summary strong {
  display: block;
}

.teacher-summary span {
  color: var(--ink-soft);
  font-size: .7rem;
}

.teacher-summary strong {
  color: var(--sky-strong);
  font-size: 1.5rem;
}

.card-heading {
  align-items: flex-start;
  margin-bottom: .9rem;
}

.card-heading p {
  margin-bottom: .2rem;
}

.teacher-controls .card-heading > p {
  max-width: 32rem;
  margin-bottom: 0;
  color: var(--ink-soft);
  text-align: right;
  font-size: .77rem;
}

.button-group {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
}

.button-group .button {
  flex: 1 1 8rem;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .7rem;
  margin-top: 1rem;
}

.metric-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: .8rem;
  background: #fff;
}

.metric-card span,
.wallet-box span {
  display: block;
  margin-bottom: .15rem;
  color: var(--ink-soft);
  font-size: .68rem;
  font-weight: 750;
}

.metric-card strong {
  display: block;
  color: var(--ink-strong);
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
}

.teacher-alerts {
  display: grid;
  gap: .5rem;
  margin-top: .8rem;
}

.alert-row {
  border: 1px solid #e4c37b;
  border-radius: 12px;
  padding: .65rem .75rem;
  color: #664b15;
  background: var(--warning-soft);
  font-size: .76rem;
}

.country-grid,
.demand-grid,
.product-grid,
.offer-grid {
  display: grid;
  gap: .75rem;
}

.country-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-top: 5px solid var(--country-color, var(--sky));
  border-radius: 16px;
  padding: .9rem;
  background: var(--surface);
}

.country-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .7rem;
}

.country-card h3 {
  margin-bottom: .1rem;
}

.country-card header small {
  color: var(--ink-soft);
  font-size: .68rem;
}

.country-score {
  flex: 0 0 auto;
  color: var(--coral-strong);
  font-size: 1rem;
  font-weight: 900;
}

.country-stat-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .35rem;
  margin-top: .7rem;
}

.country-stat-row span {
  min-width: 0;
  border-radius: 9px;
  padding: .45rem;
  color: var(--ink-soft);
  background: var(--surface-soft);
  text-align: center;
  font-size: .67rem;
}

.country-stat-row strong {
  display: block;
  color: var(--ink-strong);
  font-size: .9rem;
}

.country-inventory {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-top: .65rem;
}

.country-trade-profile > .trade-profile {
  margin-top: 0;
}

.trade-profile {
  display: grid;
  gap: .5rem;
  margin-top: .7rem;
  border: 1px solid color-mix(in srgb, var(--sky) 32%, var(--line));
  border-radius: 13px;
  padding: .75rem;
  background: var(--sky-soft);
}

.trade-profile p {
  display: grid;
  grid-template-columns: 7rem minmax(0, 1fr);
  gap: .45rem;
  margin: 0;
  color: var(--ink-soft);
  font-size: .78rem;
}

.trade-profile strong {
  color: var(--ink-strong);
  font-size: .72rem;
}

.trade-profile small {
  color: var(--ink-soft);
  font-size: .68rem;
  line-height: 1.5;
}

.trade-profile.compact {
  padding: .55rem;
}

.trade-profile.compact p {
  grid-template-columns: 5.7rem minmax(0, 1fr);
  font-size: .68rem;
}

.trade-profile.compact strong {
  font-size: .65rem;
}

.mini-chip,
.requirement-chip,
.status-chip,
.role-chip {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  border-radius: 999px;
  padding: .28rem .55rem;
  font-size: .68rem;
  font-weight: 800;
}

.mini-chip {
  color: var(--ink-soft);
  background: var(--surface-soft);
}

.demand-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: .85rem;
  background:
    linear-gradient(140deg, #fff, var(--sky-soft));
}

.demand-card::after {
  position: absolute;
  right: -.6rem;
  bottom: -.8rem;
  color: rgb(35 108 145 / 9%);
  content: "↗";
  font-size: 4.5rem;
  font-weight: 950;
}

.demand-card strong,
.demand-card small {
  position: relative;
  z-index: 1;
  display: block;
}

.demand-card strong {
  color: var(--ink-strong);
}

.demand-card small {
  margin-top: .2rem;
  color: var(--ink-soft);
  font-size: .7rem;
}

.roster-list,
.summary-list,
.ranking-list,
.team-member-list,
.contract-list {
  display: grid;
  gap: .55rem;
}

.roster-row,
.summary-row,
.ranking-row,
.team-member,
.contract-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: .7rem;
  background: #fff;
}

.roster-row,
.team-member {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .65rem;
  align-items: center;
}

.roster-row strong,
.roster-row small,
.team-member strong,
.team-member small {
  display: block;
}

.roster-row small,
.team-member small {
  margin-top: .12rem;
  color: var(--ink-soft);
  font-size: .7rem;
}

.online-state {
  color: var(--success);
  font-size: .68rem;
  font-weight: 850;
}

.online-state.offline {
  color: var(--danger);
}

.remove-player-button {
  min-height: 36px;
  border: 1px solid #dfaaa6;
  border-radius: 9px;
  padding: .3rem .55rem;
  color: var(--danger);
  background: var(--danger-soft);
  font-size: .68rem;
  font-weight: 850;
}

.ranking-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: .55rem;
  align-items: center;
}

.ranking-row.me {
  border: 2px solid var(--coral);
  background: var(--coral-soft);
}

.rank-number {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--ink-strong);
  background: var(--sky-soft);
  font-weight: 950;
}

.ranking-row:first-child .rank-number {
  color: #6b4b04;
  background: #ffe4a0;
}

.ranking-row strong,
.ranking-row small {
  display: block;
}

.ranking-row small {
  color: var(--ink-soft);
  font-size: .68rem;
}

.ranking-score {
  color: var(--coral-strong);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.activity-list {
  display: grid;
  gap: .65rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.activity-list li {
  border-left: 3px solid var(--sky);
  padding-left: .7rem;
  color: #405668;
  font-size: .77rem;
}

.activity-list time {
  display: block;
  margin-top: .12rem;
  color: var(--ink-soft);
  font-size: .65rem;
}

.empty-state {
  min-height: 92px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 13px;
  padding: 1rem;
  color: var(--ink-soft);
  background: var(--surface-soft);
  text-align: center;
  font-size: .78rem;
}

.player-view {
  max-width: 780px;
  margin: 0 auto;
  padding-bottom: calc(86px + env(safe-area-inset-bottom));
}

.player-identity {
  flex-wrap: wrap;
  padding: .75rem .1rem;
}

.player-identity small {
  color: var(--ink-soft);
}

.wallet-box {
  flex: 0 0 auto;
  border: 1px solid #e1a59e;
  border-radius: 14px;
  padding: .55rem .75rem;
  background: var(--coral-soft);
  text-align: right;
}

.wallet-box strong {
  color: var(--coral-strong);
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
}

.player-lobby {
  min-height: 490px;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
}

.waiting-illustration {
  margin-bottom: .7rem;
  font-size: 4rem;
}

.player-lobby > p {
  max-width: 30rem;
  color: var(--ink-soft);
}

.role-picker {
  width: min(100%, 600px);
  margin: .7rem 0 1rem;
  border: 1px solid var(--line);
  border-radius: 17px;
  padding: .9rem;
  background: var(--surface-soft);
}

.country-correction {
  width: min(100%, 600px);
  margin: .7rem 0 0;
  display: grid;
  gap: .45rem;
  border: 1px solid #aac9d8;
  border-radius: 17px;
  padding: .9rem;
  background: var(--sky-soft);
  text-align: left;
}

.country-correction h3,
.country-correction p {
  margin-bottom: 0;
}

.country-correction > p {
  color: var(--ink-soft);
  font-size: .72rem;
}

.role-option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .55rem;
  margin: .7rem 0;
}

.role-option {
  position: relative;
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: .7rem;
  color: var(--ink);
  background: #fff;
  text-align: left;
}

.role-option[aria-pressed="true"] {
  border: 2px solid var(--coral);
  background: var(--coral-soft);
}

.role-option strong,
.role-option small {
  display: block;
}

.role-option small {
  margin-top: .15rem;
  color: var(--ink-soft);
  font-size: .68rem;
}

.active-role-picker {
  margin-top: .8rem;
  display: grid;
  gap: .45rem;
  border-top: 1px solid var(--line);
  padding-top: .8rem;
}

.lobby-count {
  min-width: 120px;
  border-radius: 14px;
  padding: .65rem 1rem;
  background: var(--sky-soft);
}

.lobby-count strong,
.lobby-count span {
  display: block;
}

.lobby-count strong {
  color: var(--sky-strong);
  font-size: 1.45rem;
}

.lobby-count span {
  color: var(--ink-soft);
  font-size: .7rem;
}

.game-screen {
  display: grid;
  gap: 1rem;
}

.screen-heading {
  padding: .4rem .1rem 0;
}

.next-action {
  position: relative;
  overflow: hidden;
  border-color: #e6aaa2;
  background:
    linear-gradient(135deg, var(--coral-soft), #fff);
}

.next-action::after {
  position: absolute;
  right: -1rem;
  bottom: -1.6rem;
  color: rgb(223 103 88 / 10%);
  content: "→";
  font-size: 7rem;
  font-weight: 950;
}

.next-action > * {
  position: relative;
  z-index: 1;
}

.next-action p {
  max-width: 34rem;
  margin-bottom: .8rem;
  color: #5f4946;
}

.next-action .button {
  width: 100%;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .65rem;
}

.asset-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: .75rem;
  background: #fff;
}

.asset-card header {
  display: flex;
  align-items: center;
  gap: .45rem;
}

.asset-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--sky-soft);
  font-size: 1.05rem;
}

.asset-card strong,
.asset-card small {
  display: block;
}

.asset-card small {
  color: var(--ink-soft);
  font-size: .67rem;
}

.asset-counts {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  margin-top: .55rem;
}

.asset-counts span {
  border-radius: 8px;
  padding: .3rem .45rem;
  color: var(--ink-soft);
  background: var(--surface-soft);
  font-size: .65rem;
}

.asset-counts strong {
  display: inline;
  color: var(--ink-strong);
}

.reservation-help {
  margin: .75rem 0 0;
  color: var(--ink-soft);
  font-size: .7rem;
}

.production-maker,
.market-maker {
  border-color: #aac9d8;
  background: linear-gradient(145deg, #fff, var(--sky-soft));
}

.quantity-stepper {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  gap: .4rem;
}

.quantity-stepper button {
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  color: var(--ink-strong);
  background: #fff;
  font-size: 1.2rem;
  font-weight: 900;
}

.quantity-stepper input {
  text-align: center;
  font-weight: 900;
}

.action-preview {
  min-height: 55px;
  margin: .35rem 0;
  border-left: 4px solid var(--sky-strong);
  border-radius: 0 10px 10px 0;
  padding: .65rem .75rem;
  color: #385468;
  background: rgb(255 255 255 / 76%);
  font-size: .78rem;
}

.product-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: .9rem;
  background: #fff;
}

.product-card header {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
}

.product-icon {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--coral-soft);
  font-size: 1.35rem;
}

.product-card header strong,
.product-card header small {
  display: block;
}

.product-card header small {
  color: var(--ink-soft);
  font-size: .69rem;
}

.requirement-row {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-top: .7rem;
}

.requirement-chip {
  color: var(--ink-soft);
  background: var(--surface-soft);
}

.requirement-chip.missing {
  color: var(--danger);
  background: var(--danger-soft);
}

.market-locked {
  min-height: 340px;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  background:
    linear-gradient(145deg, var(--surface-soft), #fff);
}

.market-locked > span {
  margin-bottom: .6rem;
  font-size: 3.8rem;
}

.market-locked p {
  max-width: 30rem;
  margin-bottom: 0;
  color: var(--ink-soft);
}

.filter-row {
  display: flex;
  gap: .45rem;
  max-width: 100%;
  margin: .9rem 0;
  overflow-x: auto;
  padding: 3px;
}

.filter-button {
  flex: 0 0 auto;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .45rem .8rem;
  color: var(--ink-soft);
  background: #fff;
  font-size: .76rem;
  font-weight: 850;
}

.filter-button.active {
  border-color: var(--ink);
  color: #fff;
  background: var(--ink);
}

.offer-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: .9rem;
  background: #fff;
}

.offer-card.mine {
  border-color: #e2aaa2;
  background: #fffaf8;
}

.offer-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .7rem;
}

.offer-card header small {
  color: var(--ink-soft);
  font-size: .68rem;
}

.trade-equation {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: .45rem;
  align-items: center;
  margin: .8rem 0;
}

.trade-side {
  border-radius: 12px;
  padding: .6rem;
  background: var(--surface-soft);
  text-align: center;
}

.trade-side strong,
.trade-side small {
  display: block;
}

.trade-side small {
  color: var(--ink-soft);
  font-size: .65rem;
}

.trade-arrow {
  color: var(--coral-strong);
  font-size: 1.25rem;
  font-weight: 950;
}

.offer-card .button {
  width: 100%;
}

.contract-guide {
  border-color: #e1a59e;
  background: var(--coral-soft);
}

.contract-guide p {
  margin: .25rem 0 0;
  color: #654743;
  font-size: .76rem;
}

.contract-card header {
  display: flex;
  justify-content: space-between;
  gap: .65rem;
}

.contract-card p {
  margin: .5rem 0 0;
  color: var(--ink-soft);
  font-size: .75rem;
}

.status-chip {
  flex: 0 0 auto;
  color: var(--sky-strong);
  background: var(--sky-soft);
}

.status-chip.done {
  color: var(--success);
  background: var(--success-soft);
}

.status-chip.cancelled {
  color: var(--danger);
  background: var(--danger-soft);
}

.my-country-summary {
  border: 2px solid var(--coral);
  background: var(--coral-soft);
}

.my-country-summary h3 {
  color: var(--ink-strong);
}

.reflection-questions {
  border-color: #e2aaa2;
  background: var(--coral-soft);
}

.reflection-questions ol {
  display: grid;
  gap: .55rem;
  margin: .6rem 0 0;
  padding-left: 1.3rem;
}

.reflection-questions li {
  color: #654743;
  font-size: .8rem;
  font-weight: 750;
}

.score-breakdown {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .45rem;
  margin-top: .7rem;
}

.score-breakdown div {
  border-radius: 10px;
  padding: .55rem;
  background: rgb(255 255 255 / 72%);
  text-align: center;
}

.score-breakdown span,
.score-breakdown strong {
  display: block;
}

.score-breakdown span {
  color: var(--ink-soft);
  font-size: .65rem;
}

.score-breakdown strong {
  color: var(--coral-strong);
  font-size: 1.05rem;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: .15rem;
  border-top: 1px solid var(--line-strong);
  padding:
    .38rem max(.3rem, env(safe-area-inset-right))
    max(.38rem, env(safe-area-inset-bottom))
    max(.3rem, env(safe-area-inset-left));
  background: rgb(255 255 255 / 97%);
  box-shadow: 0 -9px 24px rgb(38 59 80 / 13%);
  backdrop-filter: blur(10px);
}

.nav-button {
  min-width: 0;
  min-height: 58px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: .08rem;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: .25rem;
  color: var(--ink-soft);
  background: transparent;
}

.nav-button > span {
  font-size: 1.15rem;
  line-height: 1;
}

.nav-button small {
  font-size: .65rem;
  font-weight: 850;
}

.nav-button.active {
  border-color: #e6afa8;
  color: var(--coral-strong);
  background: var(--coral-soft);
}

dialog {
  width: min(100% - 1.5rem, 480px);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 0;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 25px 80px rgb(23 42 58 / 28%);
}

dialog::backdrop {
  background: rgb(23 42 58 / 56%);
  backdrop-filter: blur(3px);
}

dialog form {
  padding: 1.3rem;
}

dialog p {
  color: var(--ink-soft);
  white-space: pre-line;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .6rem;
}

.toast {
  position: fixed;
  right: .75rem;
  bottom: calc(79px + env(safe-area-inset-bottom));
  left: .75rem;
  z-index: 80;
  max-width: 540px;
  margin: 0 auto;
  border: 1px solid rgb(255 255 255 / 35%);
  border-radius: 14px;
  padding: .8rem 1rem;
  color: #fff;
  background: var(--ink-strong);
  box-shadow: 0 12px 34px rgb(0 0 0 / 25%);
  text-align: center;
  font-size: .82rem;
  font-weight: 800;
}

noscript {
  display: block;
  margin: 1rem;
  border: 2px solid var(--danger);
  border-radius: 14px;
  padding: 1rem;
  background: var(--danger-soft);
  text-align: center;
}

@media (min-width: 620px) {
  main {
    width: min(100% - 2rem, 1180px);
  }

  .site-header {
    width: min(100% - 2.5rem, 1180px);
  }

  .brand strong {
    font-size: 1.1rem;
  }

  .brand small {
    font-size: .74rem;
  }

  .metric-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .country-grid,
  .product-grid,
  .offer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .demand-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .asset-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .bottom-nav {
    right: 50%;
    left: auto;
    width: min(100% - 2rem, 750px);
    transform: translateX(50%);
    border: 1px solid var(--line-strong);
    border-bottom: 0;
    border-radius: 18px 18px 0 0;
  }
}

@media (min-width: 840px) {
  .landing-view {
    grid-template-columns: 1.04fr .96fr;
    align-items: stretch;
    margin-top: 2rem;
  }

  .welcome-card,
  .entry-card {
    min-height: 650px;
  }

  .teacher-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(290px, .78fr);
    align-items: start;
    gap: 1rem;
  }

  .teacher-side {
    position: sticky;
    top: 6.3rem;
  }

  .roster-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .site-header {
    min-height: 70px;
  }

  .brand small {
    display: none;
  }

  .connection-badge {
    max-width: 108px;
    white-space: normal;
    text-align: center;
  }

  .welcome-card {
    min-height: auto;
    padding: 1.15rem;
  }

  .welcome-card h1 {
    margin-bottom: .7rem;
    font-size: 2rem;
  }

  .welcome-lead {
    font-size: .88rem;
  }

  .feature-list small {
    display: none;
  }

  .learning-notice {
    margin-top: 1rem;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .session-toolbar {
    align-items: flex-start;
    padding-block: .6rem;
  }

  .mode-badge {
    display: none;
  }

  .round-bar {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: .65rem .75rem;
  }

  .round-bar-center {
    grid-column: 1 / -1;
    grid-row: 2;
    min-width: 0;
    border: 0;
    border-top: 1px solid rgb(255 255 255 / 20%);
    padding: .45rem 0 0;
    text-align: left;
  }

  .round-bar time {
    grid-column: 2;
    grid-row: 1;
  }

  .teacher-heading,
  .card-heading {
    align-items: flex-start;
  }

  .teacher-heading {
    display: grid;
  }

  .teacher-summary {
    width: 100%;
    text-align: left;
  }

  .teacher-controls .card-heading {
    display: grid;
  }

  .teacher-controls .card-heading > p {
    text-align: left;
  }

  .room-code-line {
    align-items: stretch;
    flex-direction: column;
  }

  .room-code-line > strong {
    font-size: 2rem;
  }

  .role-option-grid,
  .asset-grid {
    grid-template-columns: 1fr;
  }

  .trade-equation {
    grid-template-columns: 1fr;
  }

  .trade-arrow {
    transform: rotate(90deg);
    text-align: center;
  }

  .score-breakdown {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}

@media (prefers-contrast: more) {
  :root {
    --line: #7e929f;
    --line-strong: #536b7a;
  }

  .card,
  .button,
  input,
  select {
    box-shadow: none;
  }
}
