:root {
  --ink: #16233d;
  --muted: #60708b;
  --paper: #f8fbff;
  --line: #d9e4f4;
  --blue: #2878f0;
  --blue-dark: #1355bd;
  --cyan: #31c5e7;
  --mint: #defff5;
  --warm: #fff6db;
  --danger: #bb4960;
  font-family: ui-rounded, "SF Pro Rounded", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
body {
  min-width: 320px;
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 14%, rgba(112, 208, 255, .54), transparent 29rem),
    radial-gradient(circle at 89% 84%, rgba(177, 239, 255, .62), transparent 28rem),
    linear-gradient(135deg, #eaf4ff 0%, #f9fcff 52%, #eaf9ff 100%);
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.app-shell { width: min(100% - 32px, 1060px); margin: 0 auto; padding: 42px 0; }
.game-card {
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.86);
  border-radius: 30px;
  background: rgba(255,255,255,.83);
  box-shadow: 0 22px 60px rgba(52, 102, 165, .2);
  backdrop-filter: blur(12px);
}
.game-header { display: flex; align-items: center; gap: 16px; padding: 28px 32px 24px; border-bottom: 1px solid var(--line); }
.brand-mark { display: grid; place-items: center; flex: 0 0 auto; width: 58px; height: 58px; border-radius: 18px; color: #fff; font: 800 23px/1 Georgia, serif; letter-spacing: -3px; background: linear-gradient(145deg, var(--blue), var(--cyan)); box-shadow: 0 10px 22px rgba(34,119,230,.28); }
.eyebrow { margin: 0 0 5px; color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .13em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: clamp(23px, 4vw, 32px); letter-spacing: -.04em; }
.subtitle { margin: 0; color: var(--muted); font-size: 14px; }
.icon-button { margin-left: auto; border: 1px solid #c9dcf8; border-radius: 12px; padding: 10px 14px; color: var(--blue-dark); background: #f2f8ff; font-weight: 750; cursor: pointer; }
.icon-button:hover { background: #e4f1ff; }

.control-panel { display: flex; gap: 22px; align-items: center; justify-content: space-between; padding: 18px 32px; background: rgba(240,247,255,.65); border-bottom: 1px solid var(--line); }
.difficulty-group { display: flex; gap: 10px; margin: 0; padding: 0; border: 0; }
.difficulty-group legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.difficulty-group label { position: relative; cursor: pointer; }
.difficulty-group input { position: absolute; opacity: 0; pointer-events: none; }
.difficulty-group span { display: block; border: 1px solid #d5e1f2; border-radius: 999px; padding: 8px 12px; color: #526681; background: #fff; font-size: 13px; font-weight: 700; transition: .18s ease; }
.difficulty-group b { color: var(--blue); font-size: 11px; }
.difficulty-group input:checked + span { border-color: var(--blue); color: var(--blue-dark); background: #eaf3ff; box-shadow: 0 0 0 3px rgba(40,120,240,.11); }
.action-group { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }
.button { border: 0; border-radius: 12px; padding: 10px 15px; font-weight: 800; cursor: pointer; transition: transform .16s ease, box-shadow .16s ease, background .16s ease; }
.button:hover:not(:disabled) { transform: translateY(-2px); }
.button:active:not(:disabled) { transform: translateY(0); }
.button:disabled { cursor: not-allowed; opacity: .44; }
.primary { color: white; background: linear-gradient(135deg, #2e82f5, #1764d7); box-shadow: 0 7px 15px rgba(37,112,226,.22); }
.secondary { color: #24548d; background: #e9f3ff; }
.ghost { color: #7d4260; background: #fff1f4; }

.status-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; padding: 20px 32px; }
.stat { display: grid; gap: 4px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.stat span { color: var(--muted); font-size: 12px; font-weight: 700; }
.stat strong { color: var(--ink); font-size: 21px; letter-spacing: -.04em; }

.play-area { padding: 0 32px 24px; }
.message-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 47px; }
.message-row p { margin: 0; font-weight: 750; }
.hint { color: #7b8aa1; font-size: 12px; }
.game-board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; min-height: 360px; padding: 16px; border: 1px solid #d6e7fc; border-radius: 22px; background: linear-gradient(135deg, #f5faff, #eef7ff); }
.game-board.empty { display: grid; place-items: center; }
.empty-copy { margin: 0; color: #7a8ca6; text-align: center; font-size: 16px; line-height: 1.8; }
.word-card { position: relative; min-height: 86px; border: 1px solid rgba(146,181,226,.58); border-radius: 17px; padding: 12px 10px; color: #1d3962; background: #fff; box-shadow: 0 5px 0 rgba(151,184,220,.38), 0 8px 15px rgba(58,104,156,.08); font-size: clamp(14px, 2vw, 18px); font-weight: 800; cursor: pointer; overflow-wrap: anywhere; transition: transform .15s ease, box-shadow .15s ease, opacity .2s ease, background .2s ease; }
.word-card:hover:not(:disabled) { transform: translateY(-3px); box-shadow: 0 8px 0 rgba(151,184,220,.38), 0 12px 20px rgba(58,104,156,.13); }
.word-card::after { position: absolute; top: 9px; right: 10px; color: #9aafc7; font-size: 10px; font-weight: 700; content: attr(data-language); }
.word-card.selected { border-color: #efb941; color: #674304; background: var(--warm); box-shadow: 0 0 0 3px rgba(246,192,74,.24), 0 5px 0 #e5bb5c; }
.word-card.correct { border-color: #59cda4; color: #177557; background: var(--mint); animation: matched .36s ease both; }
.word-card.wrong { border-color: #e58b9a; background: #fff1f3; animation: shake .32s linear; }
.word-card.eliminated { opacity: .26; cursor: default; box-shadow: none; transform: scale(.96); }
.word-card:disabled { pointer-events: none; }
@keyframes matched { 50% { transform: scale(1.06); } 100% { transform: scale(.96); } }
@keyframes shake { 25% { transform: translateX(-5px); } 70% { transform: translateX(5px); } }
.game-footer { padding: 16px 32px; color: #70819b; border-top: 1px solid var(--line); background: rgba(248,251,255,.8); text-align: center; font-size: 12px; }

dialog { border: 0; border-radius: 24px; padding: 0; color: var(--ink); background: transparent; box-shadow: 0 24px 75px rgba(16,38,72,.3); }
dialog::backdrop { background: rgba(19,37,67,.43); backdrop-filter: blur(4px); }
.dialog-card { width: min(92vw, 590px); padding: 26px; border: 1px solid rgba(255,255,255,.8); border-radius: 24px; background: #fff; }
.dialog-heading { display: flex; align-items: start; justify-content: space-between; gap: 18px; }
.dialog-heading h2, .result-card h2 { margin-bottom: 4px; font-size: 26px; }
.close-button { width: 34px; height: 34px; border: 0; border-radius: 50%; color: #637592; background: #edf4fb; font-size: 25px; cursor: pointer; line-height: 1; }
.add-pair { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; margin-top: 20px; }
.add-pair label { display: grid; gap: 6px; color: #516684; font-size: 12px; font-weight: 800; }
.add-pair input { min-width: 0; border: 1px solid #ccdeef; border-radius: 10px; padding: 10px; color: var(--ink); outline: none; }
.add-pair input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(40,120,240,.12); }
.form-note { min-height: 18px; margin: 11px 0; color: #6f829d; font-size: 12px; }
.word-list { display: grid; gap: 8px; max-height: 270px; margin: 0; padding: 0; overflow: auto; list-style: none; }
.word-list li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: #f4f8fd; color: #3a577d; font-weight: 700; }
.word-list .translation { color: #7489a5; font-size: 13px; }
.delete-word { margin-left: auto; border: 0; border-radius: 8px; padding: 5px 8px; color: var(--danger); background: #fff0f2; cursor: pointer; font-size: 12px; font-weight: 800; }
.empty-list { justify-content: center; color: #8ca0b8; font-size: 13px; font-weight: 600; }
.result-card { text-align: center; }
.result-card p:not(.eyebrow) { color: #61738d; line-height: 1.7; }
.result-actions { display: flex; justify-content: center; gap: 10px; margin-top: 20px; }

@media (max-width: 720px) {
  .app-shell { width: min(100% - 20px, 1060px); padding: 12px 0; }
  .game-card { border-radius: 22px; }
  .game-header, .control-panel, .play-area, .game-footer { padding-left: 18px; padding-right: 18px; }
  .game-header { align-items: flex-start; }
  .brand-mark { width: 48px; height: 48px; border-radius: 15px; }
  .control-panel { align-items: stretch; flex-direction: column; }
  .difficulty-group { justify-content: space-between; }
  .difficulty-group span { padding: 8px 10px; }
  .action-group { justify-content: stretch; }
  .action-group .button { flex: 1; padding: 10px 8px; font-size: 13px; }
  .status-grid { gap: 8px; padding: 16px 18px; }
  .stat { padding: 10px; }
  .stat strong { font-size: 18px; }
  .message-row { align-items: flex-start; flex-direction: column; padding-top: 4px; gap: 3px; }
  .game-board { grid-template-columns: repeat(2, minmax(0, 1fr)); min-height: 320px; padding: 10px; gap: 10px; }
  .word-card { min-height: 70px; }
  .add-pair { grid-template-columns: 1fr; }
  .add-pair .button { width: 100%; }
}
