* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #1b5fb8;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: #fff;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
canvas#game { display: block; touch-action: none; cursor: crosshair; }

.hidden { display: none !important; }
.muted { color: rgba(255, 255, 255, 0.75); }
.small { font-size: 13px; }

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(8, 28, 60, 0.35);
  overflow-y: auto;
}
.overlay.passthrough { pointer-events: none; background: none; }

.card {
  width: min(720px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 24px 28px;
  border-radius: 20px;
  background: linear-gradient(160deg, rgba(20, 50, 100, 0.92), rgba(70, 20, 60, 0.92));
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.15);
}
h1 {
  margin: 0;
  font-size: clamp(34px, 6vw, 54px);
  font-weight: 900;
  letter-spacing: -1px;
  background: linear-gradient(90deg, #ffd60a, #ff9f1c, #ff006e);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tag { margin: 4px 0 18px; color: rgba(255, 255, 255, 0.85); }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 28px; }
@media (max-width: 600px) { .grid { grid-template-columns: 1fr; } .card { padding: 18px; } }

.field { display: block; margin-bottom: 14px; font-size: 14px; font-weight: 600; color: rgba(255, 255, 255, 0.9); }
.field input[type=text], .field input:not([type]) {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  font-size: 16px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.25);
  color: #fff;
  -webkit-user-select: text;
  user-select: text;
}
input[type=range] { width: 100%; margin-top: 8px; accent-color: #ffd60a; }

.swatches, .patterns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.swatches button {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid transparent; cursor: pointer; padding: 0;
}
.swatches button.sel { border-color: #fff; transform: scale(1.12); }
.patterns canvas {
  width: 52px; height: 52px; border-radius: 10px; cursor: pointer;
  background: rgba(255, 255, 255, 0.08); border: 2px solid transparent;
}
.patterns canvas.sel { border-color: #fff; background: rgba(255, 255, 255, 0.2); }

.seg { display: flex; margin-top: 6px; border-radius: 10px; overflow: hidden; border: 1px solid rgba(255, 255, 255, 0.25); }
.seg button {
  flex: 1; padding: 8px; border: 0; cursor: pointer; font-weight: 600;
  background: rgba(0, 0, 0, 0.2); color: #fff;
}
.seg button.sel { background: #ffd60a; color: #222; }
.seg.disabled, .field.disabled { opacity: 0.5; pointer-events: none; }

.buttons { display: flex; gap: 12px; margin: 18px 0 6px; flex-wrap: wrap; }
.buttons button {
  flex: 1; min-width: 160px; padding: 14px 18px; font-size: 18px; font-weight: 800;
  border-radius: 14px; border: 0; cursor: pointer; transition: transform 0.1s;
}
.buttons button:active { transform: scale(0.97); }
.buttons button:disabled { opacity: 0.45; cursor: not-allowed; }
.primary { background: linear-gradient(90deg, #ffd60a, #ff9f1c); color: #3a1c00; }
.secondary { background: rgba(255, 255, 255, 0.15); color: #fff; border: 1px solid rgba(255, 255, 255, 0.3) !important; }

#lanNote code, #lanNote b { color: #ffd60a; }
#lanNote a { color: #8ecbff; }

details { margin-top: 10px; background: rgba(0, 0, 0, 0.18); border-radius: 12px; padding: 10px 14px; }
summary { cursor: pointer; font-weight: 700; }
.how { padding-left: 18px; margin: 10px 0 0; line-height: 1.5; font-size: 14px; }
kbd { background: rgba(255, 255, 255, 0.2); border-radius: 4px; padding: 1px 6px; font-size: 12px; }

#corner { position: fixed; right: 12px; bottom: 12px; display: flex; gap: 8px; z-index: 5; }
#corner button {
  width: 42px; height: 42px; border-radius: 12px; border: 0; cursor: pointer;
  background: rgba(10, 30, 60, 0.5); color: #fff; font-size: 18px;
}

#hint {
  position: fixed; left: 50%; bottom: 120px; transform: translateX(-50%);
  display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;
  pointer-events: none; transition: opacity 1s; width: max-content; max-width: 95vw;
}
#hint span { background: rgba(10, 30, 60, 0.6); padding: 8px 12px; border-radius: 10px; font-size: 14px; }
#hint.fade { opacity: 0; }

.results { width: min(440px, 100%); text-align: center; }
.results h2 { margin: 0 0 12px; font-size: 30px; }
.results ol { list-style: none; padding: 0; margin: 0; text-align: left; }
.results li {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; margin-bottom: 6px;
  border-radius: 10px; background: rgba(255, 255, 255, 0.08); font-size: 16px;
}
.results li.me { background: rgba(255, 214, 10, 0.25); }
.results li .dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.results li .nm { flex: 1; }
.results li .st { color: rgba(255, 255, 255, 0.7); font-size: 13px; }
.results li .sc { font-weight: 900; min-width: 48px; text-align: right; }
