/* Manga-page look: ink outlines, hard offset shadows, halftone paper. The 3x3 is the "splash panel". */
:root {
  --paper: #f1efff; --card: #ffffff; --ink: #15122b; --muted: #5b5878;
  --sakura: #ff5c93; --cobalt: #3b4bff; --sun: #ffd447; --mint: #12b886; --alert: #e03131;
  --line: 3px solid var(--ink); --shadow: 5px 5px 0 var(--ink); --r: 10px;
  --font: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --display: "Arial Black", "Segoe UI Black", Impact, system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --paper: #15122b; --card: #231f45; --ink: #f4f1ff; --muted: #b3afd6; --shadow: 5px 5px 0 #000; --line: 3px solid #f4f1ff; }
}
* { box-sizing: border-box; }
html { scroll-padding-top: 5rem; }
body { margin: 0; font: 16px/1.5 var(--font); color: var(--ink); background: var(--paper);
  background-image: radial-gradient(color-mix(in srgb, var(--ink) 9%, transparent) 1.2px, transparent 1.4px); background-size: 14px 14px; min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--cobalt); font-weight: 700; } a:hover { color: var(--sakura); }
:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); line-height: 1.1; margin: 0 0 .6rem; letter-spacing: -.02em; }
h1 { font-size: clamp(2rem, 6vw, 3.4rem); font-style: italic; } h2 { font-size: 1.5rem; } h3 { font-size: 1.15rem; }
p { margin: 0 0 1rem; } .muted { color: var(--muted); } .error-text { color: var(--alert); font-weight: 700; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 8px; top: 8px; background: var(--sun); color: #000; padding: .5rem 1rem; z-index: 99; }
main { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 1.5rem 1rem 3rem; outline: none; }
.foot { text-align: center; font-size: .85rem; color: var(--muted); padding: 1.5rem 1rem; }

/* top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #15122b;
  color: #f4f1ff;
  border-bottom: 4px solid var(--sakura);
}
.topbar-in { max-width: 1080px; margin: 0 auto; display: flex; align-items: center; gap: .75rem; padding: .55rem 1rem; flex-wrap: wrap; }
.brand { font-family: var(--display); font-style: italic; font-size: 1.25rem; color: #f4f1ff; text-decoration: none; margin-right: auto; }
.brand b { color: var(--sun); }
.topbar nav { display: flex; gap: .25rem; flex-wrap: wrap; align-items: center; }
.topbar nav a, .topbar nav button { color: #f4f1ff; text-decoration: none; padding: .35rem .7rem; border-radius: 6px; background: none; border: 0; font: inherit; font-weight: 700; cursor: pointer; }
.topbar nav a:hover, .topbar nav button:hover, .topbar nav a[aria-current] { background: var(--sakura); color: #fff; }
.menu-btn { display: none; }
@media (max-width: 720px) { .menu-btn { display: inline-block; } .topbar nav { display: none; width: 100%; flex-direction: column; align-items: stretch; } .topbar nav.open { display: flex; } }

/* buttons & forms */
.btn { display: inline-block; font: inherit; font-weight: 800; background: var(--sun); color: #15122b; border: var(--line); border-radius: var(--r); padding: .6rem 1.1rem; cursor: pointer; box-shadow: 3px 3px 0 var(--ink); text-decoration: none; transition: transform .08s, box-shadow .08s; }
.btn:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); color: #15122b; }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn.primary { background: var(--sakura); color: #fff; } .btn.primary:hover { color: #fff; }
.btn.ghost { background: var(--card); color: var(--ink); } .btn.danger { background: var(--alert); color: #fff; } .btn.ok { background: var(--mint); color: #04261b; }
.btn.small { padding: .3rem .7rem; font-size: .9rem; } .btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; box-shadow: 3px 3px 0 var(--ink); }
.icon-btn { background: none; border: 0; color: inherit; font-size: 1.1rem; cursor: pointer; padding: .3rem .5rem; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; } .row.end { justify-content: flex-end; } .row.between { justify-content: space-between; }
.panel { background: var(--card); border: var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 1.25rem; margin-bottom: 1.5rem; }
.field { display: flex; flex-direction: column; gap: .3rem; font-weight: 700; margin-bottom: 1rem; }
input, select, textarea { font: inherit; font-weight: 400; color: var(--ink); background: var(--paper); border: var(--line); border-radius: 8px; padding: .55rem .7rem; width: 100%; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--sakura); transform: scale(1.3); margin-right: .5rem; }
.fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
}
.narrow { max-width: 440px; margin-inline: auto; }
.choice { display: flex; align-items: flex-start; gap: .5rem; padding: .7rem; border: var(--line); border-radius: 8px; margin-bottom: .6rem; cursor: pointer; background: var(--paper); }
.choice:has(input:checked) { background: var(--sun); color: #15122b; }
.notice { border: var(--line); border-left-width: 10px; border-radius: 8px; padding: .8rem 1rem; background: var(--paper); margin-bottom: 1rem; }
.notice.warn { border-left-color: var(--sun); } .notice.bad { border-left-color: var(--alert); } .notice.good { border-left-color: var(--mint); }
.pill { display: inline-block; padding: .1rem .6rem; border: 2px solid var(--ink); border-radius: 99px; font-weight: 800; font-size: .8rem; background: var(--sun); color: #15122b; }
.pill.approved { background: var(--mint); } .pill.rejected { background: var(--alert); color: #fff; }

/* hero */
.hero { display: grid; grid-template-columns: 1.1fr .9fr; gap: 2rem; align-items: center; margin-bottom: 2rem; }
.hero h1 { margin-bottom: 1rem; } .hero .lead { font-size: 1.2rem; max-width: 34ch; }
.hero .grid3 { transform: rotate(2deg); }
@media (max-width: 800px) { .hero { grid-template-columns: 1fr; } .hero .grid3 { transform: none; } }
.cta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; }
.cta-grid .panel {
  margin: 0;
  display: flex;
  flex-direction: column;
}

.cta-grid .panel .btn {
  margin-top: auto;
  align-self: flex-start;
}

.cta-grid h3 {
  margin-bottom: .4rem;
}

/* THE 3x3 */
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 8px; background: var(--ink); border: var(--line); border-radius: var(--r); box-shadow: var(--shadow); max-width: 520px; width: 100%; margin-inline: auto; }
.grid3.big { max-width: 600px; margin-bottom: 1.5rem;}
.cell-wrap { position: relative; }
.cell { position: relative; display: block; width: 100%; aspect-ratio: 2 / 3; padding: 0; overflow: hidden; border: 0; border-radius: 4px; background: var(--card); color: var(--ink); cursor: default; }
button.cell { cursor: pointer; } button.cell:hover { outline: 4px solid var(--sun); z-index: 1; }
.cell:not(.filled) { background: repeating-linear-gradient(135deg, var(--paper) 0 8px, var(--card) 8px 16px); display: grid; place-items: center; }
.cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.plus { font: 900 2.2rem var(--display); color: var(--muted); }
.cell-title { position: absolute; inset: auto 0 0 0; padding: 1.4rem .4rem .35rem; font-size: .72rem; font-weight: 800; line-height: 1.15; color: #fff; background: linear-gradient(transparent, rgba(10, 8, 30, .92)); text-shadow: 0 1px 2px #000; }
.cell-year { position: absolute; top: 4px; left: 4px; background: var(--sun); color: #15122b; font-size: .65rem; font-weight: 900; padding: 0 .35rem; border-radius: 4px; }
.cell-x { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; background: var(--alert); color: #fff; font-weight: 900; cursor: pointer; z-index: 2; line-height: 1; }
.nocover { display: grid; place-items: center; width: 100%; height: 100%; background: var(--sakura); color: #fff; font: 900 2rem var(--display); }
@media (max-width: 480px) { .cell-title { font-size: .6rem; padding-top: 1rem; } .grid3 { gap: 5px; padding: 5px; } }

/* modal & search */
.overlay { position: fixed; inset: 0; background: rgba(10, 8, 30, .7); z-index: 50; display: grid; place-items: center; padding: 1rem; overflow: auto; }
.modal { background: var(--card); border: var(--line); border-radius: var(--r); box-shadow: var(--shadow); width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; padding: 1rem 1.25rem 1.25rem; } .modal.wide { max-width: 760px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; } .modal-head h2 { margin: 0; font-size: 1.2rem; }
.results { margin-top: 1rem; display: grid; gap: .5rem; max-height: 55vh; overflow: auto; }
.result { display: flex; gap: .75rem; align-items: center; text-align: left; font: inherit; color: var(--ink); background: var(--paper); border: 2px solid var(--ink); border-radius: 8px; padding: .4rem; cursor: pointer; }
.result:hover:not([disabled]) { background: var(--sun); color: #15122b; } .result[disabled] { opacity: .45; cursor: not-allowed; }
.result img, .result .nocover { width: 46px; height: 66px; object-fit: cover; border-radius: 4px; flex: none; }
.result-text { display: flex; flex-direction: column; } .result-text small { color: var(--muted); }

/* identity */
.avatar { width: 48px; height: 48px; border-radius: 50%; border: var(--line); object-fit: cover; background: var(--paper); } .avatar.lg { width: 84px; height: 84px; } .avatar.xl { width: 128px; height: 128px; }
.identity { display: flex; align-items: center; gap: 1rem; justify-content: center; margin: 1.25rem 0; } .id-name { font: 900 1.5rem var(--display); display: block; }

/* game */
.stage { text-align: center; } .stage .fields { text-align: left; max-width: 640px; margin-inline: auto; }
.score-burst { display: inline-block; background: var(--sun); color: #15122b; border: var(--line); box-shadow: var(--shadow); padding: .4rem 2rem; transform: rotate(-2deg) skewX(-6deg); margin: .5rem 0 1.25rem; }
.score-burst b { font: 900 clamp(2.6rem, 10vw, 4.5rem) var(--display); } .score-burst span { font: 800 1.4rem var(--display); }
.break { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; text-align: left; margin-bottom: 1.5rem; }
.break .panel { margin: 0; } .break dl { margin: .4rem 0; } .break dt { color: var(--muted); font-size: .85rem; } .break dd { margin: 0 0 .3rem; font-weight: 700; }
.pts { font: 900 1.4rem var(--display); } .pts.full { color: var(--mint); } .pts.zero { color: var(--alert); }

/* tables / lists */
table { width: 100%; border-collapse: collapse; } th, td { padding: .6rem .5rem; text-align: left; border-bottom: 2px solid color-mix(in srgb, var(--ink) 15%, transparent); } th { font-size: .85rem; color: var(--muted); }
td.user { display: flex; align-items: center; gap: .6rem; font-weight: 700; } .tabs { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tab { font: inherit; font-weight: 800; border: var(--line); border-radius: 99px; background: var(--card); color: var(--ink); padding: .3rem 1rem; cursor: pointer; } .tab[aria-pressed=true] { background: var(--ink); color: var(--paper); }
.me-row { background: var(--sun); color: #15122b; } .stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; }
.stat { background: var(--card); border: var(--line); border-radius: var(--r); padding: .8rem 1rem; box-shadow: 3px 3px 0 var(--ink); } .stat b { display: block; font: 900 1.8rem var(--display); } .stat span { color: var(--muted); font-size: .85rem; }
.sub-card { display: grid; grid-template-columns: minmax(180px, 260px) 1fr; gap: 1.25rem; } @media (max-width: 700px) { .sub-card { grid-template-columns: 1fr; } }
.sub-card .grid3 { box-shadow: 3px 3px 0 var(--ink); } .sub-card dl { display: grid; grid-template-columns: auto 1fr; gap: .1rem .8rem; margin: .5rem 0; } .sub-card dt { color: var(--muted); }
.bars { display: grid; gap: .4rem; } .bar { display: grid; grid-template-columns: 6.5rem 1fr auto; gap: .6rem; align-items: center; font-size: .9rem; } .bar i { display: block; height: 14px; background: var(--sakura); border: 2px solid var(--ink); border-radius: 4px; }

/* skeletons / toasts / empty */
.skeletons { display: grid; gap: .75rem; } .skel { height: 80px; border-radius: var(--r); background: linear-gradient(90deg, color-mix(in srgb, var(--ink) 8%, transparent) 25%, color-mix(in srgb, var(--ink) 16%, transparent) 50%, color-mix(in srgb, var(--ink) 8%, transparent) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; } .skel.row { height: 66px; }
.skeletons.grid { grid-template-columns: repeat(3, 1fr); max-width: 520px; margin-inline: auto; } .skeletons.grid .skel { height: auto; aspect-ratio: 2/3; }
@keyframes shimmer { to { background-position: -200% 0; } }
.toasts { position: fixed; bottom: 1rem; right: 1rem; left: 1rem; display: flex; flex-direction: column; align-items: flex-end; gap: .5rem; z-index: 90; pointer-events: none; }
.toast { pointer-events: auto; background: var(--ink); color: var(--paper); border: 3px solid var(--sun); border-radius: 8px; padding: .6rem 1rem; font-weight: 700; max-width: 420px; box-shadow: var(--shadow); animation: pop .18s ease-out; } .toast.error { border-color: var(--alert); } .toast.success { border-color: var(--mint); }
@keyframes pop { from { transform: translateY(10px) scale(.96); opacity: 0; } }
.empty { text-align: center; padding: 2rem 1rem; } .empty.error { border-color: var(--alert); }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }


/* תיקוני טבלה ולידרבורד למסכי טלפון - גרסה קשיחה ומיושרת */
@media (max-width: 550px) {

  /* צמצום שוליים בפאנל */
  .panel {
    padding: 1rem 0.25rem;
  }

  /* הכרחת הטבלה לשמור על חלוקה קבועה ויישור אמצע */
  table {
    table-layout: fixed;
    width: 100%;
  }

  table th,
  table td {
    padding: 0.5rem 0.2rem;
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    vertical-align: middle;
    /* יישור אנכי מדויק לכל העמודות */
  }

  /* חלוקת אחוזים מדויקת */
  th:nth-child(1),
  td:nth-child(1) {
    width: 15%;
  }

  th:nth-child(2),
  td:nth-child(2) {
    width: 44%;
  }

  th:nth-child(3),
  td:nth-child(3) {
    width: 21%;
  }

  th:nth-child(4),
  td:nth-child(4) {
    width: 20%;
  }

  /* ביטול הפלקס - מחזיר את הקו המפריד להיות אחיד וישר */
  td.user {
    display: table-cell;
  }

  /* התאמת התמונה ליישור אמצע קלאסי */
  .avatar {
    width: 24px !important;
    height: 24px !important;
    color: transparent;
    display: inline-block;
    vertical-align: middle;
    margin-right: 5px;
  }

  /* הכרחת הטקסט להחתך עם 3 נקודות תוך שמירה על יישור לאמצע התמונה */
  td.user a,
  td.user span {
    display: inline-block;
    vertical-align: middle;
    max-width: calc(100% - 32px);
    /* מחשב את הרווח שנשאר אחרי התמונה */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* התאמת הכפתור */
  .btn.small.ghost {
    padding: 0.2rem 0.3rem;
    font-size: 0.7rem;
    width: 100%;
    text-align: center;
  }
}