* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #10222e;
  color: #f0f4f5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- header ---------- */
header {
  background: #173342;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 5;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
}

header h1 {
  font-size: 17px;
  margin: 0;
  color: #ffd166;
  letter-spacing: 1px;
  white-space: nowrap;
}

#banner {
  flex: 1;
  text-align: center;
  font-size: 13px;
  color: #cfe0ea;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#banner.your-turn { color: #7cfc9a; font-weight: 700; }

.room {
  font-size: 11px;
  color: #9db8c7;
  background: #0f2735;
  border: 1px solid #2c5062;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

#rules-btn {
  border-radius: 50%;
  width: 28px;
  height: 28px;
  border: none;
  background: #ffd166;
  color: #10222e;
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
  flex: none;
}

/* ---------- sections ---------- */
section { padding: 8px 10px; }

#opponent { background: #142a38; }

#opponent .waiting {
  font-size: 13px;
  opacity: .85;
  text-align: center;
  padding: 8px 4px;
}

.opp-name { font-size: 13px; font-weight: 700; margin-bottom: 6px; }

.opp-row { display: flex; gap: 10px; align-items: flex-start; justify-content: center; }

.mini-pile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  position: relative;
}

.mini-label { font-size: 9px; opacity: .7; }
.mini-count { font-size: 10px; opacity: .85; }
.mini-empty { width: 34px; height: 48px; }

/* ---------- center ---------- */
#center { display: flex; gap: 12px; align-items: flex-start; justify-content: center; flex-wrap: wrap; }

.pile { display: flex; flex-direction: column; align-items: center; gap: 4px; }

.cap { font-size: 11px; color: #b9d0dd; min-height: 14px; }

.placeholder {
  font-size: 10px;
  color: #7f9aab;
  border: 1.5px dashed #4a6a7a;
  border-radius: 8px;
  padding: 5px 6px;
}

.building .placeholder, .stock .placeholder { margin-top: 16px; }

/* ---------- cards ---------- */
.card {
  width: 54px;
  height: 76px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .45);
  border: 2px solid #dfe6ea;
  background: linear-gradient(160deg, #ffffff, #eef2f4);
  color: #16324a;
  position: relative;
  flex: none;
}

.card-num .card-label { font-size: 22px; }

.card-skip {
  background: linear-gradient(160deg, #43b35f, #2c8a46);
  border-color: #eaffef;
  color: #eaffef;
}

.card-skip .card-label { font-size: 12px; letter-spacing: 1px; }

.card-back {
  background: repeating-linear-gradient(45deg, #2a5878, #2a5878 7px, #1d4158 7px, #1d4158 14px);
  border-color: #0f2735;
}

.back-star { color: #ffd166; font-size: 20px; }

.card.clickable { cursor: pointer; }

.pile.clickable { cursor: pointer; }

.pile.discard-target .placeholder {
  border-color: #7cfc9a;
  color: #7cfc9a;
  background: rgba(124, 252, 154, .08);
}

.card.selected {
  outline: 3px solid #ffd166;
  transform: translateY(-7px);
  box-shadow: 0 6px 10px rgba(0, 0, 0, .5);
}

.card-big { width: 62px; height: 86px; }
.card-med { width: 54px; height: 76px; }
.card-small { width: 44px; height: 62px; }
.card-small .card-label { font-size: 16px; }
.card-skip.card-small .card-label { font-size: 9px; }
.card-mini { width: 34px; height: 48px; border-radius: 6px; }
.card-mini .card-label { font-size: 12px; }
.card-skip.card-mini .card-label { font-size: 7px; }

/* ---------- player area ---------- */
#player { display: flex; gap: 14px; justify-content: center; align-items: flex-start; }

#stock { display: flex; flex-direction: column; gap: 4px; align-items: center; }

#discards { display: flex; gap: 8px; align-items: flex-start; }

/* ---------- hand ---------- */
#hand {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  padding: 12px 8px 22px;
  min-height: 115px;
}

.pass-btn {
  background: #ffd166;
  color: #10222e;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 13px;
}

/* ---------- toast ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 70px;
  transform: translateX(-50%);
  background: rgba(20, 40, 55, .96);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid #ffd166;
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
  z-index: 40;
  font-size: 13px;
  max-width: 90vw;
  text-align: center;
}

#toast.show { opacity: 1; }
#toast.error { border-color: #ff6b6b; background: rgba(70, 22, 22, .96); }

/* ---------- overlay ---------- */
#overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 18, 24, .93);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  z-index: 50;
  text-align: center;
  padding: 20px;
}

#overlay.hidden { display: none; }

.winner-name { font-size: 34px; font-weight: 800; color: #ffd166; }
.winner-detail { font-size: 14px; opacity: .92; max-width: 80vw; }

.new-game {
  background: #ffd166;
  color: #10222e;
  border: none;
  border-radius: 10px;
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
}

/* ---------- rules modal ---------- */
#rules-modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 18, 24, .93);
  z-index: 60;
  overflow: auto;
  padding: 20px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

#rules-modal.hidden { display: none; }

.rules-box {
  background: #eef2f4;
  color: #16324a;
  border-radius: 12px;
  max-width: 620px;
  width: 100%;
  padding: 18px 20px;
  font-size: 14px;
  line-height: 1.5;
}

.rules-box h2 { margin-top: 0; }
.rules-box ol { margin: 0 0 12px; padding-left: 20px; }
.rules-box li { margin-bottom: 8px; }

#close-rules {
  background: #2c8a46;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
}

/* ---------- landing page ---------- */
body.landing {
  background: linear-gradient(170deg, #10222e 0%, #173342 100%);
  justify-content: center;
}

.landing-box {
  max-width: 420px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.landing-title {
  text-align: center;
  font-size: 40px;
  letter-spacing: 3px;
  color: #ffd166;
  margin: 8px 0 4px;
  text-shadow: 0 3px 8px rgba(0, 0, 0, .5);
}

.sub {
  text-align: center;
  font-size: 13px;
  opacity: .85;
  margin: 0 0 18px;
}

.resume {
  display: block;
  text-align: center;
  color: #7cfc9a;
  margin-bottom: 10px;
  font-size: 14px;
}

.form-error {
  background: #4a1c1c;
  color: #ffb3b3;
  border: 1px solid #ff6b6b;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
}

.card-form {
  background: #173342;
  border: 1px solid #2c5062;
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
}

.card-form h2 { margin: 0 0 12px; font-size: 15px; color: #ffd166; }

.card-form label {
  display: block;
  font-size: 12px;
  opacity: .9;
  margin-bottom: 10px;
}

.card-form input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 10px;
  font-size: 16px;
  border-radius: 8px;
  border: 1px solid #3a5d70;
  background: #0f2735;
  color: #fff;
}

.card-form button {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  font-weight: 800;
  border: none;
  border-radius: 8px;
  background: #ffd166;
  color: #10222e;
  cursor: pointer;
}

.hint { font-size: 11px; opacity: .75; margin: 10px 0 0; }

.howto {
  text-align: center;
  font-size: 12px;
  opacity: .8;
  line-height: 1.6;
}

.howto code { background: #0f2735; padding: 1px 6px; border-radius: 5px; color: #ffd166; }
