/* ===== קלף פתוח — עיצוב משודרג v1.1 ===== */
:root {
  --bg: #F6F5FB;
  --bg-glow: #EEE9FF;
  --surface: rgba(255, 255, 255, 0.94);
  --surface-solid: #FFFFFF;
  --surface-muted: #FCFBFF;
  --ink: #221A3F;
  --muted: #736C8F;
  --muted-light: #A79FC4;
  --line: #E5E2F2;
  --line-strong: #D7D2EA;
  --primary: #5B2EFF;
  --primary-hover: #4E24E8;
  --primary-soft: #EEE9FF;
  --primary-ring: rgba(91, 46, 255, 0.18);
  --danger: #D6303B;
  --success: #2FA36B;

  --deck-friends: #FF7A00;
  --deck-family: #2FA36B;
  --deck-army: #7A8B3A;
  --deck-girls: #E8438F;
  --deck-adult: #D6303B;

  --radius-sm: 12px;
  --radius-md: 16px;
  --radius: 20px;
  --radius-lg: 26px;
  --shadow-sm: 0 6px 18px rgba(34, 26, 63, 0.07);
  --shadow: 0 14px 40px rgba(34, 26, 63, 0.11);
  --shadow-hover: 0 18px 48px rgba(34, 26, 63, 0.15);
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body { min-height: 100%; }
html { background: var(--bg); }

body {
  font-family: 'Rubik', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background:
    radial-gradient(circle at 85% 0%, rgba(91, 46, 255, 0.11), transparent 30%),
    radial-gradient(circle at 8% 34%, rgba(232, 67, 143, 0.06), transparent 26%),
    linear-gradient(180deg, #FAF9FE 0%, var(--bg) 54%, #F3F1FA 100%);
  background-attachment: fixed;
  color: var(--ink);
  direction: rtl;
  line-height: 1.55;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input { font-family: inherit; }
button { touch-action: manipulation; }

#app {
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 18px 16px 20px;
}

h1, h2, .display {
  font-family: 'Secular One', 'Rubik', sans-serif;
  font-weight: 400;
  letter-spacing: 0.01em;
}

/* ---- כותרת עליונה ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 2px 18px;
}

.brand {
  font-family: 'Secular One', sans-serif;
  font-size: 23px;
  line-height: 1;
  color: var(--primary);
  text-shadow: 0 4px 14px rgba(91, 46, 255, 0.12);
}

.topbar .user {
  min-width: 0;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  gap: 10px;
  align-items: center;
}

.topbar .user > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.linkbtn {
  appearance: none;
  background: none;
  border: none;
  color: var(--primary);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  border-radius: 8px;
  padding: 3px 5px;
  transition: background-color 180ms ease, color 180ms ease;
}

.linkbtn:focus-visible {
  outline: 3px solid var(--primary-ring);
  outline-offset: 2px;
}

/* ---- טפסים ופאנלים ---- */
.panel {
  position: relative;
  background: var(--surface);
  border: 1px solid rgba(229, 226, 242, 0.94);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 7px;
}

input[type=text], input[type=password] {
  width: 100%;
  min-height: 50px;
  padding: 13px 15px;
  font: inherit;
  font-size: 16px;
  border: 1.5px solid var(--line);
  border-radius: 13px;
  background: var(--surface-muted);
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.8);
  transition: border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

input::placeholder { color: #A39CB9; opacity: 1; }

input:hover { border-color: var(--line-strong); }

input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface-solid);
  box-shadow: 0 0 0 4px var(--primary-ring);
}

.btn {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  padding: 14px 18px;
  font: inherit;
  font-size: 17px;
  line-height: 1.2;
  font-weight: 700;
  border: 1px solid transparent;
  border-radius: 15px;
  cursor: pointer;
  background: linear-gradient(135deg, #6539FF 0%, var(--primary) 58%, #4D23E8 100%);
  color: #fff;
  box-shadow: 0 9px 20px rgba(91, 46, 255, 0.23);
  transition: transform 220ms var(--ease), box-shadow 220ms var(--ease), opacity 180ms ease, background-color 180ms ease;
}

.btn:active { transform: translateY(1px) scale(0.985); }
.btn:focus-visible { outline: 4px solid var(--primary-ring); outline-offset: 2px; }
.btn:disabled { opacity: 0.46; cursor: not-allowed; box-shadow: none; transform: none; }

.btn.secondary {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: rgba(91, 46, 255, 0.10);
  box-shadow: none;
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  box-shadow: none;
}

.btn.danger {
  background: #FDECEC;
  color: var(--danger);
  box-shadow: none;
}

.btn + .btn { margin-top: 11px; }

.error {
  background: #FFF0F1;
  color: var(--danger);
  border: 1px solid rgba(214, 48, 59, 0.12);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.45;
  margin-bottom: 16px;
}

.hint {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--muted);
  text-align: center;
  margin-top: 15px;
}

/* ---- מסך פתיחה / התחברות ---- */
.hero { text-align: center; padding: 38px 0 26px; }

.hero .logo {
  font-family: 'Secular One', sans-serif;
  font-size: clamp(44px, 12vw, 54px);
  color: var(--primary);
  line-height: 1.05;
  letter-spacing: -0.02em;
  text-shadow: 0 10px 28px rgba(91, 46, 255, 0.15);
}

.hero .tag {
  color: var(--muted);
  font-size: 15.5px;
  margin-top: 8px;
  letter-spacing: 0.01em;
}

/* ---- בחירת חפיסה ---- */
.decks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0 18px;
}

.deck-btn {
  position: relative;
  overflow: hidden;
  min-height: 130px;
  border: 1.5px solid var(--line);
  border-radius: 18px;
  background: var(--surface-solid);
  padding: 18px 12px;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: transform 220ms var(--ease), border-color 220ms ease, box-shadow 220ms var(--ease), background-color 220ms ease;
}

.deck-btn::after {
  content: '';
  position: absolute;
  inset: auto -28px -36px auto;
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--deck-color, var(--primary)) 10%, transparent);
  pointer-events: none;
}

.deck-btn:active { transform: scale(0.975); }
.deck-btn:focus-visible { outline: 4px solid var(--primary-ring); outline-offset: 2px; }

.deck-btn .emoji {
  position: relative;
  z-index: 1;
  font-size: 32px;
  line-height: 1;
  display: block;
  margin-bottom: 9px;
  filter: drop-shadow(0 4px 7px rgba(34, 26, 63, 0.10));
}

.deck-btn .name {
  position: relative;
  z-index: 1;
  display: block;
  font-weight: 700;
  font-size: 16px;
  line-height: 1.3;
}

.deck-btn .sub {
  position: relative;
  z-index: 1;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--muted);
  margin-top: 5px;
}

.deck-btn.selected {
  border-color: var(--deck-color, var(--primary));
  background: color-mix(in srgb, var(--deck-color, var(--primary)) 7%, #fff);
  box-shadow: 0 10px 26px color-mix(in srgb, var(--deck-color, var(--primary)) 18%, transparent);
  transform: translateY(-2px);
}

.deck-btn.selected::before {
  content: '✓';
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--deck-color, var(--primary));
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 5px 12px color-mix(in srgb, var(--deck-color, var(--primary)) 30%, transparent);
}

.deck-btn.wide { grid-column: 1 / -1; min-height: 112px; }

.agegate {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  background: #FFF7F0;
  border: 1px solid rgba(214, 48, 59, 0.09);
  border-radius: 13px;
  padding: 13px 14px;
  font-size: 13.5px;
  line-height: 1.5;
  margin-bottom: 16px;
}

.agegate input {
  flex: 0 0 auto;
  margin-top: 2px;
  width: 19px;
  height: 19px;
  accent-color: var(--danger);
}

/* ---- לובי ---- */
.code-box { text-align: center; padding: 24px 0 10px; }
.code-box .label { font-size: 13.5px; color: var(--muted); }

.code-box .code {
  font-family: 'Secular One', sans-serif;
  font-size: clamp(50px, 16vw, 64px);
  line-height: 1.1;
  letter-spacing: 0.32em;
  color: var(--ink);
  direction: ltr;
  display: inline-block;
  margin: 7px 0 5px;
  padding-inline-start: 0.32em;
  text-shadow: 0 8px 20px rgba(34, 26, 63, 0.10);
}

.players {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  justify-content: center;
  margin: 18px 0 22px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(255,255,255,.88);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(34,26,63,.04);
  transition: border-color 180ms ease, background-color 180ms ease, transform 180ms ease;
}

.chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #C9C4DD;
  box-shadow: 0 0 0 3px rgba(201,196,221,.22);
}

.chip.online .dot { background: var(--success); box-shadow: 0 0 0 3px rgba(47,163,107,.14); }
.chip.turn { border-color: var(--primary); background: var(--primary-soft); transform: translateY(-1px); }
.chip.me { font-weight: 700; }
.chip .crown { font-size: 12px; }

/* ---- הקלף ---- */
.card-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 10px 0 18px;
}

.game-card {
  position: relative;
  background: var(--surface-solid);
  border-radius: var(--radius-lg);
  box-shadow: 0 22px 55px rgba(34, 26, 63, 0.15);
  border: 1px solid rgba(229, 226, 242, 0.95);
  overflow: hidden;
  min-height: 330px;
  display: flex;
  flex-direction: column;
  animation: deal 420ms var(--ease);
}

.game-card::after {
  content: '';
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(229, 226, 242, 0.48);
  border-radius: 18px;
  pointer-events: none;
}

@keyframes deal {
  from { transform: translateY(24px) rotate(-1.4deg) scale(.985); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.game-card .band { height: 11px; background: var(--deck-color, var(--primary)); }

.game-card .card-head {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 17px 20px 0;
}

.tagchip {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--deck-color, var(--primary));
  background: color-mix(in srgb, var(--deck-color, var(--primary)) 11%, #fff);
  border: 1px solid color-mix(in srgb, var(--deck-color, var(--primary)) 15%, #fff);
  border-radius: 999px;
  padding: 5px 12px;
}

.counter { font-size: 13px; color: var(--muted); direction: ltr; }

.game-card .q {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px 28px 32px;
  font-size: clamp(23px, 6.4vw, 28px);
  line-height: 1.48;
  font-weight: 500;
}

.turn-banner {
  text-align: center;
  font-size: 15.5px;
  color: var(--muted);
  margin: 17px 0 13px;
}

.turn-banner b { color: var(--primary); }

.game-actions { display: flex; gap: 11px; }
.game-actions .btn { margin-top: 0; }
.game-actions .btn.skip { flex: 0 0 35%; }

/* ---- סיום ---- */
.finale { text-align: center; padding: 48px 24px; }
.finale .big { font-size: 58px; filter: drop-shadow(0 9px 18px rgba(34,26,63,.12)); }
.finale h2 { font-size: 28px; margin: 12px 0 7px; }
.finale p { color: var(--muted); line-height: 1.65; }

.footer-note {
  text-align: center;
  font-size: 12.5px;
  color: var(--muted-light);
  padding: 16px 0 5px;
}

/* ---- מחשב / מכשיר עם עכבר ---- */
@media (hover: hover) and (pointer: fine) {
  .linkbtn:hover { background: var(--primary-soft); color: var(--primary-hover); }
  .btn:not(:disabled):hover { transform: translateY(-2px); box-shadow: 0 13px 26px rgba(91, 46, 255, 0.28); }
  .btn.secondary:not(:disabled):hover { background: #E6DFFF; box-shadow: none; }
  .btn.ghost:not(:disabled):hover { background: rgba(115,108,143,.08); box-shadow: none; }
  .deck-btn:hover { transform: translateY(-3px); border-color: var(--line-strong); box-shadow: var(--shadow-hover); }
  .deck-btn.selected:hover { border-color: var(--deck-color, var(--primary)); }
}

/* ---- מסכים קטנים ---- */
@media (max-width: 370px) {
  #app { padding-inline: 12px; }
  .panel { padding: 20px 17px; }
  .decks { gap: 9px; }
  .deck-btn { min-height: 126px; padding-inline: 8px; }
  .deck-btn .sub { font-size: 12px; }
  .game-actions { gap: 8px; }
  .game-actions .btn { padding-inline: 10px; font-size: 15.5px; }
}

/* ---- נגישות תנועה ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---- הערת קלף רגיש ---- */
.card-note {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  padding: 0 24px 18px;
  line-height: 1.4;
}

/* ---- בורר עוצמה ---- */
.levels-block {
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px 14px 14px;
  margin-bottom: 16px;
}
.block-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 10px;
}
.levels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.level-btn {
  border: 1.5px solid var(--line);
  background: var(--surface-solid);
  border-radius: var(--radius-sm);
  padding: 10px 4px 8px;
  font: inherit;
  cursor: pointer;
  text-align: center;
  opacity: 0.42;
  transition: opacity 0.18s var(--ease), border-color 0.18s var(--ease), transform 0.1s var(--ease);
}
.level-btn:active { transform: scale(0.96); }
.level-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.level-btn.on { opacity: 1; border-color: var(--line-strong); }
.level-btn.edge { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.level-btn .ldot { display: block; font-size: 17px; line-height: 1.3; }
.level-btn .lname { display: block; font-size: 11.5px; font-weight: 500; color: var(--muted); }
.level-btn.on .lname { color: var(--ink); }
.level-note {
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
  margin-top: 9px;
  min-height: 17px;
}
.toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 13px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
  cursor: pointer;
}
.toggle-row b { color: var(--ink); font-weight: 500; }
.toggle-row input {
  margin-top: 2px;
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  accent-color: var(--primary);
}
.code-box .label.intensity { margin-top: 3px; }

@media (prefers-reduced-motion: reduce) {
  .level-btn { transition: none; }
}
