:root {
  color-scheme: light;
  font-family: "Pretendard", "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  font-synthesis: none;
  --ink: #18251f;
  --muted: #58685f;
  --surface: #ffffff;
  --surface-soft: #f7faf5;
  --canvas: #f0f5ec;
  --line: #cad8cd;
  --brand: #21604f;
  --brand-strong: #174638;
  --brand-soft: #dcefe5;
  --accent: #e2a53a;
  --accent-soft: #fff2d4;
  --blue: #225b8e;
  --blue-soft: #e1effc;
  --danger: #a52b25;
  --danger-soft: #fde7e5;
  --warning: #76530a;
  --warning-soft: #fff0bf;
  --success: #19643e;
  --success-soft: #def3e6;
  --focus: #7a3ce7;
  --shadow: 0 12px 32px rgb(34 65 49 / 9%);
  --radius-lg: 22px;
  --radius-md: 15px;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgb(244 208 137 / 25%), transparent 22rem),
    linear-gradient(180deg, #f8fbf4 0, var(--canvas) 42rem);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: radial-gradient(rgb(33 96 79 / 10%) 1px, transparent 1px);
  background-size: 22px 22px;
  content: "";
  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(1.8rem, 8vw, 3.4rem);
  line-height: 1.18;
  letter-spacing: -.035em;
}

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

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

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

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  top: .5rem;
  left: .5rem;
  z-index: 100;
  transform: translateY(-180%);
  border-radius: 10px;
  padding: .75rem 1rem;
  color: #fff;
  background: var(--ink);
}

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

.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;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  width: min(100% - 1.5rem, 1180px);
  min-height: 76px;
  margin: 0 auto;
  padding: max(.7rem, env(safe-area-inset-top)) 0 .65rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 2px solid var(--brand);
  border-radius: 14px;
  color: #fff;
  background: var(--brand);
  font-size: 1.3rem;
  font-weight: 900;
}

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

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

.brand small {
  margin-top: .05rem;
  color: var(--muted);
  font-size: .7rem;
}

.connection-badge,
.status-pill,
.count-badge {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  border: 1px solid #d5b460;
  border-radius: 999px;
  padding: .32rem .66rem;
  color: var(--warning);
  background: var(--warning-soft);
  font-size: .76rem;
  font-weight: 850;
  white-space: nowrap;
}

.connection-badge::before {
  width: 8px;
  height: 8px;
  margin-right: .38rem;
  border-radius: 50%;
  background: currentcolor;
  content: "";
}

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

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

main {
  width: min(100% - 1.25rem, 1180px);
  margin: 0 auto;
  padding: .7rem 0 calc(2rem + env(safe-area-inset-bottom));
}

.landing-view {
  display: grid;
  gap: 1rem;
  max-width: 980px;
  margin: 1rem auto 0;
}

.welcome-card,
.entry-card,
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgb(255 255 255 / 94%);
  box-shadow: var(--shadow);
}

.welcome-card {
  position: relative;
  overflow: hidden;
  padding: clamp(1.4rem, 6vw, 3.4rem);
}

.welcome-card::after {
  position: absolute;
  right: -45px;
  bottom: -55px;
  width: 180px;
  height: 180px;
  border: 24px solid rgb(226 165 58 / 18%);
  border-radius: 50%;
  content: "";
}

.welcome-card h1 {
  max-width: 13ch;
  margin-bottom: 1rem;
  color: var(--brand-strong);
}

.eyebrow {
  margin-bottom: .25rem;
  color: var(--brand);
  font-size: .75rem;
  font-weight: 900;
  letter-spacing: .08em;
}

.lead {
  position: relative;
  z-index: 1;
  max-width: 35rem;
  margin-bottom: 1.25rem;
  color: #425349;
  font-size: 1.02rem;
  line-height: 1.7;
}

.feature-list {
  position: relative;
  z-index: 1;
  display: grid;
  gap: .55rem;
  margin: 0 0 1.2rem;
  padding: 0;
  list-style: none;
}

.feature-list li {
  display: flex;
  align-items: center;
  gap: .65rem;
  font-weight: 750;
}

.feature-list span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 11px;
  background: var(--brand-soft);
}

.health-status {
  margin: 0;
  color: var(--muted);
  font-size: .82rem;
}

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

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

.entry-card {
  overflow: hidden;
}

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

.role-tab {
  min-height: 52px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--muted);
  background: transparent;
  font-weight: 850;
}

.role-tab:hover {
  background: #fff;
}

.role-tab.active {
  border-color: var(--line);
  color: var(--brand-strong);
  background: #fff;
  box-shadow: 0 3px 12px rgb(34 65 49 / 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 h3,
.screen-heading h2,
.teacher-heading h2,
.session-toolbar h1,
.player-identity h2 {
  margin-bottom: 0;
}

.section-icon {
  display: grid;
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 16px;
  background: var(--accent-soft);
  font-size: 1.65rem;
}

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

label,
legend {
  color: #293c32;
  font-size: .9rem;
  font-weight: 850;
}

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

input::placeholder {
  color: #7c8d83;
}

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

.field-help {
  margin: -.15rem 0 .35rem;
  color: var(--muted);
  font-size: .78rem;
}

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

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

.alliance-entry-fields,
.alliance-teacher-settings {
  display: grid;
  gap: .5rem;
  min-width: 0;
  margin: .45rem 0;
  border: 1px solid #9db7d0;
  border-radius: 15px;
  padding: .85rem;
  background: var(--blue-soft);
}

.alliance-entry-fields legend {
  padding: 0 .35rem;
  color: var(--blue);
}

.country-brief {
  min-height: 2.75rem;
  margin: -.1rem 0 .35rem;
  border-left: 4px solid var(--blue);
  border-radius: 0 9px 9px 0;
  padding: .55rem .65rem;
  color: #29485f;
  background: #f7fbff;
  font-size: .78rem;
}

.alliance-teacher-settings > .field-help {
  margin-bottom: 0;
}

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

.check-row input {
  width: 24px;
  min-height: 24px;
  margin: .18rem 0 0;
  accent-color: var(--brand);
}

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

.check-row small {
  margin-top: .15rem;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 500;
}

.advanced-settings {
  margin: .2rem 0 .5rem;
  border-top: 1px solid var(--line);
  padding-top: .5rem;
}

.advanced-settings summary {
  min-height: 48px;
  padding: .7rem 0;
  color: var(--muted);
  font-size: .85rem;
  font-weight: 800;
  cursor: pointer;
}

.advanced-settings[open] {
  display: grid;
  gap: .45rem;
}

.button {
  min-height: 48px;
  border: 1.5px solid #91a89a;
  border-radius: 12px;
  padding: .62rem 1rem;
  color: #25382e;
  background: #fff;
  font-weight: 850;
}

.button:hover:not(:disabled) {
  background: #edf5f0;
}

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

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

.button.secondary {
  border-color: #90a79a;
  color: var(--brand-strong);
  background: #f7faf8;
}

.button.quiet {
  border-color: transparent;
  color: var(--muted);
  background: transparent;
}

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

.button.warning {
  border-color: #b37a12;
  color: #533a08;
  background: #ffda87;
}

.button.wide {
  width: 100%;
  margin-top: .55rem;
}

.button.compact {
  min-height: 48px;
  padding-inline: .78rem;
  font-size: .83rem;
}

.form-message {
  min-height: 1.45rem;
  margin: .15rem 0 0;
  color: var(--muted);
  font-size: .83rem;
}

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

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

.session-view {
  max-width: 1180px;
  margin: 0 auto;
}

.session-toolbar {
  margin: .5rem 0 .8rem;
  padding: .2rem;
}

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

.mode-badge {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  margin-top: .35rem;
  border: 1px solid #78a990;
  border-radius: 999px;
  padding: .2rem .6rem;
  color: var(--brand-strong);
  background: var(--brand-soft);
  font-size: .72rem;
  font-weight: 900;
}

.mode-badge.limited {
  border-color: #d2a852;
  color: #664604;
  background: #fff3d3;
}

.mode-badge.alliance {
  border-color: #8ab0d1;
  color: #173f63;
  background: var(--blue-soft);
}

.round-bar {
  position: sticky;
  top: .5rem;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .7rem;
  margin-bottom: 1rem;
  border: 1px solid #9eb5a7;
  border-radius: 17px;
  padding: .7rem .85rem;
  color: #fff;
  background: rgb(23 70 56 / 96%);
  box-shadow: 0 8px 20px rgb(20 51 41 / 20%);
  backdrop-filter: blur(8px);
}

.round-bar > div:first-child {
  display: grid;
  gap: .35rem;
}

.round-bar .status-pill {
  width: fit-content;
  min-height: 25px;
  border: 1px solid rgb(255 255 255 / 40%);
  padding: .2rem .55rem;
  color: #183329;
  background: #d8f4e6;
  font-size: .7rem;
}

.round-bar strong {
  font-size: .95rem;
}

.round-time {
  display: grid;
  flex: 0 0 auto;
  text-align: right;
}

.round-time span {
  color: #d3e9df;
  font-size: .68rem;
}

.round-time strong {
  font-variant-numeric: tabular-nums;
  font-size: 1.5rem;
  letter-spacing: .03em;
}

.card {
  margin-bottom: 1rem;
  padding: clamp(1rem, 4vw, 1.4rem);
}

.teacher-heading {
  align-items: flex-end;
  margin: 1rem 0;
}

.room-code-card {
  display: grid;
  gap: .25rem;
  text-align: right;
}

.room-code-card span {
  color: var(--muted);
  font-size: .75rem;
  font-weight: 750;
}

.room-code-card strong {
  color: var(--brand-strong);
  font-size: clamp(1.55rem, 6vw, 2.2rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: .1em;
}

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

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

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

.teacher-controls .card-heading > p {
  max-width: 28rem;
  margin-bottom: 0;
  text-align: right;
  font-size: .8rem;
}

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

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

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

.metric-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: .85rem;
  background: #fff;
  box-shadow: 0 5px 18px rgb(34 65 49 / 6%);
}

.metric-card span,
.score-box span {
  display: block;
  margin-bottom: .18rem;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 750;
}

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

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

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

.filter-button {
  flex: 0 0 auto;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .5rem .85rem;
  color: var(--muted);
  background: #fff;
  font-size: .83rem;
  font-weight: 800;
}

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

.player-list,
.offers-list,
.catalog-grid,
.leaderboard-list {
  display: grid;
  gap: .7rem;
}

.player-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .6rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: .72rem;
  background: var(--surface-soft);
}

.player-row-main {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: .65rem;
}

.region-symbol {
  display: grid;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  font-size: 1.35rem;
}

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

.player-row small {
  margin-top: .12rem;
  color: var(--muted);
  font-size: .72rem;
}

.player-score {
  text-align: right;
  font-size: .9rem;
  font-variant-numeric: tabular-nums;
}

.player-remove-button {
  margin-top: .45rem;
  white-space: nowrap;
}

.state-text {
  display: block;
  margin-top: .15rem;
  color: var(--success);
  font-size: .68rem;
  font-weight: 800;
}

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

.leaderboard-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: .55rem;
  align-items: center;
  min-height: 54px;
  border-bottom: 1px solid #e3ebe4;
  padding: .4rem .1rem;
}

.leaderboard-row:last-child {
  border-bottom: 0;
}

.leaderboard-row.me {
  margin-inline: -.45rem;
  border: 2px solid var(--brand);
  border-radius: 13px;
  padding-inline: .45rem;
  background: var(--brand-soft);
}

.rank-number {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 10px;
  color: var(--brand-strong);
  background: #e8f0e9;
  font-weight: 900;
}

.leaderboard-row:nth-child(1) .rank-number {
  color: #5a3b00;
  background: #ffe5a1;
}

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

.leaderboard-row small {
  color: var(--muted);
  font-size: .7rem;
}

.leaderboard-score {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.alliance-leaderboard-card {
  border-color: #9db7d0;
  background: linear-gradient(145deg, #f7fbff, #fff);
}

.alliance-leaderboard-card .rank-number {
  color: #173f63;
  background: var(--blue-soft);
}

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

.activity-list li {
  position: relative;
  border-left: 3px solid var(--brand-soft);
  padding-left: .75rem;
  color: #3b4c42;
  font-size: .84rem;
}

.activity-list time {
  display: block;
  margin-top: .15rem;
  color: var(--muted);
  font-size: .68rem;
}

.empty-state {
  display: grid;
  min-height: 100px;
  place-items: center;
  margin: .3rem 0;
  border: 1px dashed #aebdb2;
  border-radius: 14px;
  padding: 1rem;
  color: var(--muted);
  background: var(--surface-soft);
  text-align: center;
}

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

.player-identity {
  flex-wrap: wrap;
  padding-block: .85rem;
}

.score-box {
  flex: 0 0 auto;
  border-radius: 14px;
  padding: .55rem .75rem;
  background: var(--accent-soft);
  text-align: right;
}

.score-box strong {
  color: #694807;
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
}

.team-score-box {
  background: var(--blue-soft);
}

.team-score-box strong {
  color: #173f63;
}

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

.waiting-illustration,
.result-illustration {
  display: block;
  margin-bottom: .8rem;
  font-size: 4rem;
}

.player-lobby p {
  max-width: 28rem;
  color: var(--muted);
}

.alliance-lobby-selection {
  width: min(100%, 560px);
  margin: .5rem 0 1rem;
  border: 1px solid #9db7d0;
  border-radius: 16px;
  padding: .9rem;
  background: var(--blue-soft);
  text-align: left;
}

.alliance-lobby-selection > h3,
.alliance-lobby-selection > p {
  text-align: center;
}

.alliance-lobby-selection > p {
  margin-bottom: .8rem;
  font-size: .8rem;
}

.alliance-lobby-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(110px, .45fr);
  gap: .65rem;
  margin-bottom: .75rem;
}

.alliance-lobby-fields > div {
  display: grid;
  gap: .35rem;
}

.alliance-lobby-selection .form-message {
  margin-top: .35rem;
  text-align: center;
}

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

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

.lobby-count span {
  color: var(--muted);
  font-size: .72rem;
}

.screen-heading {
  margin: 1.1rem .2rem .75rem;
}

.next-action {
  overflow: hidden;
  border: 2px solid #dfb45b;
  background: linear-gradient(135deg, #fff9e9, #fff);
}

.next-action h3 {
  color: #60430a;
  font-size: 1.2rem;
}

.next-action p {
  color: #594d35;
}

.next-action .button {
  margin-top: .25rem;
}

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

.resource-card {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: .5rem;
  align-items: center;
  min-height: 70px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: .6rem;
  background: var(--surface-soft);
}

.resource-icon {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 12px;
  background: #fff;
  font-size: 1.35rem;
}

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

.resource-card small {
  color: var(--muted);
  font-size: .67rem;
}

.resource-quantity {
  margin-left: .2rem;
  color: var(--brand-strong);
  font-variant-numeric: tabular-nums;
}

.offer-maker fieldset {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: .75rem;
  background: var(--surface-soft);
}

.npc-trader-card {
  overflow: hidden;
  border: 2px solid #d2a852;
  background: linear-gradient(145deg, #fff9e9, #fff);
}

.npc-trader-heading {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .7rem;
}

.npc-trader-heading > span {
  display: grid;
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 16px;
  background: #fff0c5;
  font-size: 1.7rem;
}

.npc-trader-heading p,
.npc-trader-heading h3 {
  margin-bottom: 0;
}

.npc-trade-description {
  color: #594d35;
  line-height: 1.65;
}

.npc-trade-flow {
  display: grid;
  grid-template-columns: 1fr 30px 1fr;
  gap: .45rem;
  margin: .9rem 0;
}

.npc-trade-flow .offer-side {
  border: 1px solid #ead39e;
  background: #fffdf7;
}

.offer-maker legend {
  padding-inline: .35rem;
}

.resource-choice {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 78px;
  gap: .45rem;
  align-items: center;
}

.resource-choice label {
  font-size: .75rem;
}

.exchange-arrow {
  display: grid;
  height: 30px;
  place-items: center;
  color: var(--brand);
  font-size: 1.4rem;
  font-weight: 900;
}

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

.offer-card.mine {
  border-color: #83a9ca;
  background: var(--blue-soft);
}

.offer-owner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .65rem;
}

.offer-owner strong {
  font-size: .92rem;
}

.offer-owner span {
  border-radius: 999px;
  padding: .22rem .5rem;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: .68rem;
  font-weight: 850;
}

.offer-flow {
  display: grid;
  grid-template-columns: 1fr 28px 1fr;
  gap: .35rem;
  align-items: stretch;
  margin-bottom: .7rem;
}

.offer-side {
  display: grid;
  align-content: center;
  min-width: 0;
  border-radius: 12px;
  padding: .65rem .5rem;
  background: var(--surface-soft);
  text-align: center;
}

.offer-side span {
  color: var(--muted);
  font-size: .67rem;
  font-weight: 800;
}

.offer-side strong {
  margin-top: .15rem;
  font-size: .88rem;
}

.offer-arrow {
  display: grid;
  place-items: center;
  color: var(--brand);
  font-size: 1.2rem;
  font-weight: 900;
}

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

.offer-warning {
  margin: 0 0 .55rem;
  color: var(--danger);
  font-size: .76rem;
  font-weight: 800;
}

.catalog-card header {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: .7rem;
  align-items: center;
  margin-bottom: .7rem;
}

.catalog-icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 14px;
  background: var(--accent-soft);
  font-size: 1.6rem;
}

.catalog-card h3,
.catalog-card header p {
  margin-bottom: 0;
}

.catalog-card header p {
  margin-top: .15rem;
  color: var(--muted);
  font-size: .76rem;
}

.requirement-list {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin: .7rem 0;
  padding: 0;
  list-style: none;
}

.requirement-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .28rem .55rem;
  color: #394a40;
  background: var(--surface-soft);
  font-size: .75rem;
  font-weight: 750;
}

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

.catalog-effect {
  margin: .45rem 0;
  border-left: 4px solid var(--brand);
  padding: .45rem .65rem;
  color: #34483d;
  background: var(--brand-soft);
  font-size: .82rem;
}

.catalog-card .button {
  width: 100%;
  margin-top: .35rem;
}

.my-rank {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: .7rem;
  border: 2px solid var(--brand);
  background: var(--brand-soft);
}

.my-rank strong {
  color: var(--brand-strong);
  font-size: 1.8rem;
}

.my-rank p {
  margin-bottom: 0;
  color: var(--muted);
}

.ranking-hidden {
  display: grid;
  min-height: 220px;
  place-items: center;
  border: 1px dashed #96aa9d;
  border-radius: 17px;
  padding: 1.2rem;
  background: var(--surface-soft);
  text-align: center;
}

.ranking-hidden span {
  display: block;
  margin-bottom: .6rem;
  font-size: 3rem;
}

.reflection-screen {
  padding-top: 1.4rem;
  text-align: center;
}

.reflection-screen > h2 {
  max-width: 22ch;
  margin-inline: auto;
}

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

.reflection-stat {
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: .9rem .6rem;
  background: #fff;
}

.reflection-stat span,
.reflection-stat strong {
  display: block;
}

.reflection-stat span {
  color: var(--muted);
  font-size: .72rem;
}

.reflection-stat strong {
  margin-top: .15rem;
  color: var(--brand-strong);
  font-size: 1.35rem;
}

.reflection-question {
  border-color: #dfb45b;
  background: var(--accent-soft);
}

.reflection-question p {
  margin-bottom: 0;
  color: #4e4025;
  line-height: 1.7;
}

.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 #9fb3a5;
  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 -8px 22px rgb(34 65 49 / 12%);
  backdrop-filter: blur(10px);
}

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

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

.nav-button strong {
  font-size: .68rem;
}

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

.nav-notification {
  position: absolute;
  top: 3px;
  right: calc(50% - 23px);
  display: grid;
  min-width: 20px;
  height: 20px;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 999px;
  padding: 0 .2rem;
  color: #fff;
  background: var(--danger);
  font-size: .62rem;
  font-weight: 900;
}

.confirm-dialog {
  width: min(calc(100% - 1.5rem), 440px);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 0;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 25px 70px rgb(0 0 0 / 30%);
}

.confirm-dialog::backdrop {
  background: rgb(12 25 19 / 65%);
}

.confirm-dialog form {
  padding: 1.3rem;
}

.confirm-dialog p {
  color: var(--muted);
  line-height: 1.65;
}

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

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

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.12rem;
  }

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

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

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

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

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

  .bottom-nav {
    right: 50%;
    left: auto;
    width: min(100% - 2rem, 730px);
    transform: translateX(50%);
    border: 1px solid #9fb3a5;
    border-bottom: 0;
    border-radius: 18px 18px 0 0;
  }
}

@media (min-width: 820px) {
  .landing-view {
    grid-template-columns: 1.03fr .97fr;
    align-items: stretch;
    margin-top: 2.2rem;
  }

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

  .teacher-grid {
    grid-template-columns: minmax(0, 1.65fr) minmax(290px, .8fr);
    align-items: start;
  }

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

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

  .toast {
    bottom: 1rem;
  }
}

@media (max-width: 480px) {
  .landing-view {
    margin-top: .35rem;
  }

  .welcome-card {
    padding: 1rem 1.1rem;
  }

  .welcome-card h1 {
    margin-bottom: .55rem;
    font-size: 1.75rem;
  }

  .welcome-card .lead {
    margin-bottom: .6rem;
    font-size: .9rem;
    line-height: 1.5;
  }

  .welcome-card .feature-list {
    display: none;
  }

  .brand small {
    display: none;
  }

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

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

  .alliance-lobby-fields {
    grid-template-columns: 1fr;
  }

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

  .teacher-heading {
    display: grid;
  }

  .room-code-card {
    width: 100%;
    border-radius: 15px;
    padding: .75rem;
    background: var(--brand-soft);
    text-align: left;
  }

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

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

  .resource-choice {
    grid-template-columns: minmax(0, 1fr) 72px;
  }

  .resource-choice label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@media (prefers-contrast: more) {
  :root {
    --line: #687b6f;
    --muted: #3c4b43;
  }

  .card,
  .welcome-card,
  .entry-card {
    border-width: 2px;
  }
}
