/* قصاص الأثر — بأسلوب كرتون التسعينات: خط أسود عريض، ألوان صارخة مسطحة، ظلال صلبة مزاحة، وزخارف ممفيس */

:root {
  --ground: #3b1d8f;
  --ground2: #2a1468;
  --paper: #fff7e6;
  --paper2: #ffe9bf;
  --ink: #1b1030;
  --ink2: #3d2f5c;
  --mini: #5e4d80;
  --yel: #ffd23f;
  --yel-d: #e8a90c;
  --pink: #ff5fa2;
  --teal: #19c3b1;
  --lime: #b6e83a;
  --red: #ff4a3d;
  --org: #ff8a1f;
  --purp: #7b4dff;
  --sky: #8fdcff;
  --pc0: #ff5a3c;
  --pc1: #ffc61a;
  --pc2: #36a3ff;
  --pc3: #7fdc3a;
  --pc4: #ff6fcf;
  --pc5: #f4f1ff;
  --r: 18px;
  --bw: 3px;
  --sh: 4px 5px 0 var(--ink);
  --sh-sm: 2px 3px 0 var(--ink);
  --display: 'Lalezar', 'Baloo Bhaijaan 2', system-ui, sans-serif;
  --body: 'Baloo Bhaijaan 2', 'Rubik', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  overscroll-behavior-y: contain;
  -webkit-tap-highlight-color: transparent;
  background-color: var(--ground);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260' viewBox='0 0 260 260'%3E%3Cg fill='none' stroke='%234d29b4' stroke-width='5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 44q8-12 16 0t16 0 16 0'/%3E%3Cpath d='M160 186q8-12 16 0t16 0 16 0'/%3E%3Ccircle cx='196' cy='56' r='10'/%3E%3Cpath d='M64 172l14-24 14 24z'/%3E%3Cpath d='M118 104l12 12M130 104l-12 12'/%3E%3Cpath d='M222 124v18M213 133h18'/%3E%3C/g%3E%3Cg fill='%234d29b4'%3E%3Ccircle cx='108' cy='30' r='5'/%3E%3Ccircle cx='32' cy='226' r='5'/%3E%3Ccircle cx='238' cy='236' r='4'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 260px 260px;
}

button, .btn, .iconbtn, .pickbtn, .chipbtn, .inp, a { touch-action: manipulation; }

h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.2; font-family: var(--display); font-weight: 400; }
h1 { font-size: clamp(3.2rem, 8.5vw, 5.6rem); line-height: 1.05; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.3rem; display: flex; align-items: center; gap: .45rem; }
h4 { font-size: 1.05rem; color: var(--ink2); margin: 1rem 0 .5rem; }
p { margin: 0 0 .7rem; line-height: 1.65; }
ol, ul { margin: 0; padding-inline-start: 1.2rem; }

.mini { color: var(--mini); font-size: .9rem; line-height: 1.6; }
.warn { color: var(--ink); background: var(--yel); border: var(--bw) solid var(--ink); box-shadow: var(--sh-sm); padding: .55rem .8rem; border-radius: 12px; font-weight: 700; }

:focus-visible { outline: 3px solid var(--yel); outline-offset: 3px; }

/* ===== الشريط العلوي ===== */
.bar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--ink);
  color: var(--paper);
  padding-top: env(safe-area-inset-top);
}
.bar::after {
  content: '';
  position: absolute;
  inset-inline: 0;
  bottom: -9px;
  height: 10px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='10' viewBox='0 0 20 10'%3E%3Cpath d='M0 0h20L10 10z' fill='%231b1030'/%3E%3C/svg%3E") repeat-x;
  background-size: 20px 10px;
  pointer-events: none;
}
.bar-in { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .45rem clamp(.8rem, 3vw, 1.6rem); max-width: 1400px; margin: 0 auto; }
.mark { display: flex; align-items: center; gap: .5rem; color: var(--yel); text-decoration: none; }
.mark-glyph svg { width: 34px; height: 34px; display: block; transform: rotate(-8deg); }
.mark-word { font-family: var(--display); font-size: 1.55rem; line-height: 1; padding-top: .2rem; }
.bar-ctx { display: flex; align-items: center; gap: .5rem; }
.codechip { font-family: var(--display); font-size: 1.05rem; background: var(--yel); color: var(--ink); border: 2.5px solid var(--paper); border-radius: 10px; padding: .1rem .7rem 0; transform: rotate(-2deg); }
.netpill { font-size: .85rem; font-weight: 700; padding: .1rem .6rem; border-radius: 999px; }
.netpill.low { background: var(--red); color: var(--ink); border: 2.5px solid var(--paper); animation: shake .5s ease-in-out infinite; }
.bar .iconbtn { background: var(--paper); }

main { flex: 1; padding: clamp(1.1rem, 3vw, 1.8rem) clamp(.8rem, 3vw, 1.6rem) 3rem; width: 100%; max-width: 1400px; margin: 0 auto; }
.mini-wrap { padding: 4rem 0; text-align: center; color: var(--paper); font-family: var(--display); font-size: 1.6rem; }

/* ===== أزرار ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  min-height: 46px;
  border: var(--bw) solid var(--ink);
  background: var(--yel);
  color: var(--ink);
  font-family: var(--display);
  font-size: 1.12rem;
  line-height: 1;
  padding: .7rem 1.1rem .55rem;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: var(--sh);
  transition: transform .1s ease, box-shadow .1s ease, background-color .15s ease;
}
.btn:hover { background: #ffe066; transform: translate(-1px, -2px); box-shadow: 5px 7px 0 var(--ink); }
.btn:active { transform: translate(4px, 5px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { background: #d9d2e6; color: #6b5a8a; cursor: not-allowed; box-shadow: var(--sh-sm); transform: none; }
.btn.big { min-height: 54px; padding: .8rem 1.3rem .65rem; font-size: 1.3rem; }
.btn.ghost { background: var(--paper); }
.btn.ghost:hover { background: #fff; }
.btn.sm { min-height: 40px; padding: .5rem .8rem .4rem; font-size: 1rem; box-shadow: var(--sh-sm); }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #ff6a5f; }
.btn.quiet { margin-top: .5rem; justify-self: start; }
.btn .ico, .iconbtn .ico { width: 20px; height: 20px; flex: 0 0 auto; }

.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px;
  border-radius: 12px;
  border: var(--bw) solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--sh-sm);
  transition: transform .1s ease, box-shadow .1s ease;
}
.iconbtn.sm { width: 38px; height: 38px; border-radius: 10px; border-width: 2.5px; }
.iconbtn.sm .ico { width: 17px; height: 17px; }
.iconbtn:hover { background: var(--yel); }
.iconbtn:active { transform: translate(2px, 3px); box-shadow: none; }

.inp {
  font: inherit;
  font-size: 1.08rem;
  font-weight: 600;
  min-height: 52px;
  padding: .6rem 1rem;
  border-radius: 14px;
  border: var(--bw) solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  min-width: 0;
  box-shadow: inset 3px 3px 0 #ead9b5;
}
.inp::placeholder { color: #8a7aa6; }
.inp:focus { outline: 3px solid var(--yel); outline-offset: 2px; }
.inp.code { letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; }

.sel { display: flex; align-items: center; gap: .4rem; font-size: .95rem; font-weight: 600; color: var(--ink2); }
.sel select { font: inherit; background: var(--paper); color: var(--ink); border: 2.5px solid var(--ink); border-radius: 10px; padding: .4rem .6rem; box-shadow: var(--sh-sm); }

.row { display: flex; align-items: center; }
.row.gap { gap: .7rem; flex-wrap: wrap; }
.row.tight { margin-top: .7rem; }
.row .btn { flex: 1 1 auto; }
.pill { display: inline-block; background: var(--pink); color: var(--ink); border: 2.5px solid var(--ink); border-radius: 999px; padding: .1rem .55rem 0; font-family: var(--display); font-size: .95rem; line-height: 1.3; }

/* ===== الهوم ===== */
.home { display: flex; flex-direction: column; gap: 2rem; }
.hero { display: grid; grid-template-columns: 1.05fr .95fr; gap: clamp(1.4rem, 4vw, 3.4rem); align-items: center; }
.hero-words { padding: 1rem 0; color: var(--paper); }
.kicker {
  display: inline-flex; align-items: center; gap: .45rem;
  background: var(--teal); color: var(--ink);
  border: var(--bw) solid var(--ink); border-radius: 12px; box-shadow: var(--sh-sm);
  padding: .25rem .8rem .1rem; margin-bottom: 1rem;
  font-family: var(--display); font-size: 1.1rem;
  transform: rotate(-3deg);
}
.kmark { width: 26px; height: 26px; }
.hero h1 {
  color: var(--yel);
  -webkit-text-stroke: 8px var(--ink);
  paint-order: stroke fill;
  text-shadow: 6px 7px 0 var(--ink);
  margin-bottom: .3em;
  transform: rotate(-2deg);
  transform-origin: right center;
}
.lede { color: var(--paper); font-size: 1.15rem; max-width: 44ch; line-height: 1.75; }
.cta { display: flex; flex-direction: column; gap: .8rem; max-width: 400px; margin: 1.4rem 0 1rem; }
.joinrow { display: flex; gap: .6rem; }
.joinrow .inp { flex: 1; }
.home .mini { color: #e2d8ff; }
.hero-art-wrap {
  border-radius: 26px;
  overflow: hidden;
  border: 4px solid var(--ink);
  box-shadow: 8px 10px 0 var(--ink);
  transform: rotate(1.5deg);
  background: #3b1d8f;
}
.hero-art { display: block; width: 100%; height: auto; }

.rules { background: var(--paper); border: var(--bw) solid var(--ink); border-radius: var(--r); box-shadow: var(--sh); padding: 1rem 1.2rem; }
.rules summary { cursor: pointer; font-family: var(--display); font-size: 1.3rem; }
.rules ol { margin-top: .7rem; color: var(--ink); font-size: 1rem; }
.rules li { margin-bottom: .5rem; line-height: 1.65; }
.rules li::marker { font-family: var(--display); color: var(--pink); }
.home .rules .mini { color: var(--mini); }

/* ===== اللوبي ===== */
.lobby { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 1.3rem; align-items: start; }
.card-panel { background: var(--paper); border: var(--bw) solid var(--ink); border-radius: var(--r); box-shadow: var(--sh); padding: 1.2rem; }
.card-panel:nth-child(1) { transform: rotate(-1deg); }
.card-panel:nth-child(3) { transform: rotate(.8deg); }
.card-panel .kicker { margin-bottom: .6rem; }
.coderow { display: flex; align-items: center; gap: .8rem; }
.bcode {
  font-family: var(--display); font-weight: 400;
  font-size: 3rem; line-height: 1; letter-spacing: .18em;
  background: var(--yel); border: var(--bw) solid var(--ink); border-radius: 14px; box-shadow: var(--sh);
  padding: .35rem .5rem .1rem .3rem; font-variant-numeric: tabular-nums;
}
.plist { list-style: none; padding: 0; display: flex; flex-direction: column; gap: .5rem; margin: .7rem 0 1.1rem; }
.prow { display: flex; align-items: center; gap: .6rem; background: #fff; border: 2.5px solid var(--ink); border-radius: 12px; padding: .45rem .6rem; }
.pname { flex: 1; font-weight: 700; }
.pname em { color: var(--mini); font-style: normal; font-size: .85rem; }
.tag { font-size: .85rem; font-weight: 700; background: var(--teal); color: var(--ink); border: 2px solid var(--ink); border-radius: 8px; padding: 0 .45rem; }
.dot { width: 13px; height: 13px; border-radius: 50%; background: #c9bfdc; border: 2px solid var(--ink); }
.dot.on { background: var(--lime); }
.tiny-rules { color: var(--ink); font-size: .95rem; padding-inline-start: 1.1rem; }
.tiny-rules li { margin-bottom: .45rem; line-height: 1.6; }
.tiny-rules li::marker { font-family: var(--display); color: var(--pink); }

.av {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  font-family: var(--display); font-size: 1.1rem; line-height: 1; padding-top: .15em;
  color: var(--ink); background: var(--pc0);
  border: 2.5px solid var(--ink); box-shadow: var(--sh-sm);
  flex: 0 0 auto; overflow: hidden;
}
.av.c1 { background: var(--pc1); } .av.c2 { background: var(--pc2); } .av.c3 { background: var(--pc3); }
.av.c4 { background: var(--pc4); } .av.c5 { background: var(--pc5); }
.av.has-face { padding: 3px; }
.av .face { width: 100%; height: 100%; border-radius: 50%; display: block; border: 2px solid var(--ink); }

/* ===== شاشة اللعب ===== */
.play { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 1.3rem; align-items: start; }
.boardwrap { position: sticky; top: 74px; }
.side { display: flex; flex-direction: column; gap: 1rem; }
.dock-in { display: flex; flex-direction: column; gap: .75rem; }

/* تلميح أول مرة */
.tip { display: flex; align-items: center; gap: .55rem; background: var(--teal); border: var(--bw) solid var(--ink); border-radius: 14px; box-shadow: var(--sh-sm); padding: .45rem .55rem .45rem .65rem; animation: rise .2s ease-out; }
.tip p { margin: 0; flex: 1; font-size: .92rem; font-weight: 600; line-height: 1.5; color: var(--ink); }
.tip-ico { display: flex; flex: 0 0 auto; }
.tip-ico .ico { width: 22px; height: 22px; }

/* وضع التقريب: البورد ينسحب داخل إطاره */
.boardwrap.near { overflow: auto; max-height: 66dvh; border-radius: 20px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.boardwrap.near .board { width: 165%; max-width: none; filter: drop-shadow(4px 5px 0 var(--ink)); }
.boardwrap { -webkit-user-select: none; user-select: none; }

/* البورد */
.board { display: block; width: 100%; height: auto; max-height: calc(100dvh - 104px); overflow: visible; filter: drop-shadow(6px 8px 0 var(--ink)); }
.board text { font-family: var(--display); fill: var(--ink); }
.board .room.legal, .board .cell.legal { cursor: pointer; outline: none; }
.board .room .glow { fill: rgba(182, 232, 58, .3); stroke: var(--lime); stroke-width: 5; stroke-dasharray: 10 8; animation: march 1s linear infinite; }
.board .room.legal:hover .glow { fill: rgba(255, 210, 63, .4); stroke: var(--yel); }
.board .room.legal:focus-visible .glow { stroke: var(--pink); }
.board .room.onpath .floor { opacity: .8; }
.board .cell.legal .tile { fill: var(--lime); stroke-width: 3; transform-box: fill-box; transform-origin: center; animation: bob 1s ease-in-out infinite; }
.board .cell.legal:hover .tile { fill: var(--yel); }
.board .cell.legal:focus-visible .tile { stroke: var(--pink); stroke-width: 4; }
.board .cell .step { pointer-events: none; opacity: .7; }
.board .cell.onpath .dot { fill: var(--pink); }
.board .stamp { fill: var(--red); }
.board .pawn .turnring { transform-box: fill-box; transform-origin: center; animation: spin 5s linear infinite; }
.board .me-arrow { pointer-events: none; animation: hop .6s ease-in-out infinite alternate; }
.board .wpn, .board .tunnel { cursor: help; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes march { to { stroke-dashoffset: -36; } }
@keyframes bob { 50% { transform: scale(.9); } }
@keyframes hop { to { transform: translateY(-5px); } }
@keyframes shake { 25% { transform: rotate(-4deg); } 75% { transform: rotate(4deg); } }
@keyframes wobble { 0% { transform: rotate(0); } 30% { transform: rotate(-2.5deg) scale(1.03); } 60% { transform: rotate(1.5deg); } 100% { transform: rotate(0); } }

/* لوحات الجانب */
.panel { background: var(--paper); border: var(--bw) solid var(--ink); border-radius: var(--r); box-shadow: var(--sh); padding: .95rem 1.05rem; }
.panel h3 { margin-bottom: .55rem; }
.panel h3 .ico { width: 22px; height: 22px; padding: 3px; border: 2.5px solid var(--ink); border-radius: 50%; background: var(--yel); box-sizing: content-box; }
.panel.ask { background: var(--pink); animation: wobble .6s ease-out 1; }
.panel.ask .mini, .panel.ask p { color: var(--ink); }
.panel.wait { background: #efe6ff; }
.panel.wait h3 .ico { background: var(--sky); }
.panel.action { background: #d9fbf6; }
.panel.action h3 .ico { background: var(--teal); }
.panel.hand h3 .ico { background: var(--lime); }
.panel.feed h3 .ico { background: var(--sky); }

.turnbar { display: flex; align-items: center; justify-content: space-between; gap: .6rem; background: var(--paper); border: var(--bw) solid var(--ink); border-radius: var(--r); box-shadow: var(--sh); padding: .6rem .8rem; }
.turnbar.me { background: var(--yel); animation: wobble .6s ease-out 1; }
.tb-main { display: flex; align-items: center; gap: .65rem; }
.tb-main b { font-family: var(--display); font-weight: 400; font-size: 1.35rem; line-height: 1.1; display: block; }
.tb-main small { display: block; color: var(--ink2); font-size: .88rem; font-weight: 600; }
.turnbar .av { width: 46px; height: 46px; }
.clock {
  font-family: var(--display); font-size: 1.35rem; line-height: 1;
  font-variant-numeric: tabular-nums;
  width: 54px; height: 54px; display: grid; place-items: center; padding-top: .15em;
  background: #fff; border: var(--bw) solid var(--ink); border-radius: 50%; box-shadow: var(--sh-sm);
}
.clock.low { background: var(--red); animation: shake .4s ease-in-out infinite; }

.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: .55rem; }
.pickbtn { font: inherit; font-weight: 700; font-size: .95rem; min-height: 44px; padding: .5rem .4rem; border-radius: 12px; border: 2.5px solid var(--ink); background: #fff; color: var(--ink); cursor: pointer; box-shadow: var(--sh-sm); transition: transform .1s ease; }
.pickbtn:hover { background: var(--yel); transform: translateY(-2px); }
.pickbtn.on { background: var(--teal); }

.catrow { display: flex; gap: .5rem; align-items: flex-start; margin-bottom: .55rem; }
.catname { font-family: var(--display); font-size: 1rem; color: var(--ink2); min-width: 72px; padding-top: .4rem; }
.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chips.wrap { margin-bottom: .5rem; }

.chip {
  display: inline-flex; align-items: center; gap: .4rem;
  background: #fff; border: 2.5px solid var(--ink); border-radius: 12px; box-shadow: var(--sh-sm);
  padding: .2rem .55rem .2rem .25rem; font-size: .95rem; font-weight: 700; color: var(--ink);
}
.chip svg { width: 34px; height: 34px; border-radius: 8px; border: 2px solid var(--ink); flex: 0 0 auto; display: block; }
.chip.big { flex-direction: column; padding: .45rem; gap: .3rem; font-family: var(--display); font-weight: 400; font-size: 1.15rem; }
.chip.big svg { width: 96px; height: 96px; border-radius: 12px; border-width: 2.5px; }

.chipbtn {
  font: inherit; font-weight: 700; font-size: .92rem; color: var(--ink);
  display: inline-flex; flex-direction: column; align-items: center; gap: .3rem;
  width: 88px; padding: .4rem .35rem .3rem; text-align: center;
  background: #fff; border: var(--bw) solid var(--ink); border-radius: 14px; box-shadow: var(--sh-sm);
  cursor: pointer; transition: transform .12s ease, box-shadow .12s ease, background-color .12s ease;
}
.chipbtn svg { width: 72px; height: 72px; border-radius: 10px; border: 2.5px solid var(--ink); display: block; }
.chipbtn:hover { transform: translateY(-3px) rotate(-2deg); box-shadow: 3px 6px 0 var(--ink); }
.chipbtn.on { background: var(--yel); transform: translateY(-3px) rotate(2deg); box-shadow: 4px 7px 0 var(--ink); }

.notes { list-style: none; padding: 0; display: flex; flex-direction: column; gap: .45rem; max-height: 240px; overflow: auto; }
.notes li { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }

.feed .log { list-style: none; padding: 0 0 4px; margin: 0; max-height: 300px; overflow: auto; display: flex; flex-direction: column; gap: .4rem; font-size: .95rem; color: var(--ink); }
.feed .log li { background: #fff; border: 2px solid var(--ink); border-radius: 10px; padding: .35rem .6rem; line-height: 1.5; }
.log li.turn { background: var(--yel); font-family: var(--display); font-size: 1.05rem; }
.log li.big { background: var(--teal); font-family: var(--display); font-size: 1.1rem; }
.log li.ask { border-inline-start: 7px solid var(--pink); }
.log li.no { color: var(--mini); background: #f3ecff; }
.log li.acc.ok { background: var(--lime); font-weight: 700; }
.log li.acc.bad, .log li.bad { background: #ffd0cb; }
.log li.mini { background: transparent; border-style: dashed; }
.log .chip { background: transparent; border: none; box-shadow: none; padding: 0; }
.log .chip svg { width: 26px; height: 26px; }
.log .glass { background: var(--pink); border: 2px solid var(--ink); border-radius: 6px; padding: 0 .3rem; }

/* ===== النوافذ ===== */
.sheet {
  position: fixed;
  inset: auto 0 0 0;
  margin: 0 auto;
  max-width: 660px;
  max-height: 84dvh;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--paper);
  border: 4px solid var(--ink);
  border-bottom: none;
  border-radius: 26px 26px 0 0;
  padding: 1.2rem 1.2rem calc(1.4rem + env(safe-area-inset-bottom));
  z-index: 60;
  box-shadow: 0 -7px 0 var(--ink), 0 0 0 100vmax rgba(27, 16, 48, .55);
  animation: rise .22s cubic-bezier(.3, 1.5, .5, 1);
}
.sheet h3 { font-size: 1.6rem; }
#modal[hidden] { display: none; }
body.sheetopen { overflow: hidden; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: .8rem; }
.sheet-actions .btn { flex: 1 1 180px; }
.sheet .inp { width: 100%; }
.welcome { text-align: center; background: var(--paper); }
.welcome-art { display: flex; justify-content: center; margin-bottom: .2rem; }
.welcome-art .tour-mark { width: 68px; height: 68px; }
.welcome { display: flex; flex-direction: column; align-items: center; gap: .55rem; }
.welcome h2 { font-size: clamp(1.55rem, 6vw, 2.2rem); margin: 0; }
.welcome > p { margin: 0; max-width: 46ch; font-size: 1.02rem; line-height: 1.8; color: var(--ink2); }
.welcome .sheet-actions { width: 100%; margin-top: .5rem; gap: .7rem; }
.welcome .sheet-actions .btn { flex: 1 1 200px; }
.welcome > .mini { margin: .1rem 0 0; font-size: .85rem; }
@media (min-width: 700px) {
  .sheet {
    inset: 0;
    height: fit-content;
    margin: auto;
    max-width: 560px;
    max-height: 88dvh;
    border: 4px solid var(--ink);
    border-radius: 26px;
    padding: 1.6rem 1.8rem 1.7rem;
    box-shadow: 8px 10px 0 var(--ink), 0 0 0 100vmax rgba(27, 16, 48, .6);
  }
  .sheet.help, .sheet.rules { max-width: 640px; }
}
.helpgrid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin: .7rem 0 .2rem; }
.big-pick { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem; min-height: 84px; font-family: var(--display); font-size: 1.1rem; padding: .6rem .4rem; }
.big-pick .mini { font-weight: 600; font-size: .82rem; line-height: 1.4; }

/* ===== الجولة التعريفية ===== */
.tour { position: fixed; inset: 0; z-index: 200; }
.tour-veil { position: fixed; inset: 0; background: rgba(27, 16, 48, .84); animation: fadein .2s ease-out; }
.tour-spot {
  position: fixed; pointer-events: none; z-index: 201;
  border: 3px dashed var(--yel); border-radius: 16px;
  box-shadow: 0 0 0 100vmax rgba(27, 16, 48, .84);
  transition: left .22s ease, top .22s ease, width .22s ease, height .22s ease;
  animation: spotpulse 1.5s ease-in-out infinite;
}
.tour-card {
  position: fixed; z-index: 202; background: var(--paper);
  border: 4px solid var(--ink); border-radius: 22px; box-shadow: 8px 10px 0 var(--ink);
  padding: .7rem .95rem .95rem; max-height: 72dvh; overflow: auto; overscroll-behavior: contain;
  animation: rise .22s cubic-bezier(.3, 1.4, .5, 1);
}
.tour-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.tour-step { font-family: var(--display); font-size: .95rem; color: var(--mini); background: #fff; border: 2px solid var(--ink); border-radius: 999px; padding: 0 .55rem; }
.tour-x { width: 34px; height: 34px; display: grid; place-items: center; border: 2.5px solid var(--ink); border-radius: 10px; background: #fff; cursor: pointer; padding: 0; box-shadow: var(--sh-sm); }
.tour-x .ico { width: 17px; height: 17px; }
.tour-body { display: flex; align-items: flex-start; gap: .7rem; margin: .4rem 0 .2rem; }
.tour-figure { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; }
.tour-art { width: 72px; height: 72px; display: block; }
.tour-mark { width: 54px; height: 54px; display: block; }
.tour-figure .ico { width: 46px; height: 46px; }
.tour-chips { display: flex; gap: 3px; }
.tour-chips svg { width: 40px; height: 40px; border-radius: 7px; border: 2px solid var(--ink); display: block; }
.tour-words { flex: 1; min-width: 0; }
.tour-words h3 { font-size: 1.28rem; margin-bottom: .25rem; }
.tour-words p { margin: 0; font-size: .95rem; line-height: 1.65; font-weight: 500; }
.tour-foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: .7rem; }
.tour-nav { display: flex; gap: .5rem; }
.tour-dots { display: flex; gap: 4px; justify-content: center; margin-top: .55rem; }
.tour-dots i { width: 7px; height: 7px; border-radius: 99px; background: #d7cbe8; transition: width .2s ease, background-color .2s ease; }
.tour-dots i.on { width: 18px; background: var(--pink); }
@keyframes spotpulse { 50% { border-color: var(--lime); } }
@keyframes fadein { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(30px); } }
.sheet .chips { margin-bottom: .7rem; }
.sheet.end { text-align: center; background: var(--yel); }
.sheet.end h2 { font-size: clamp(2rem, 6vw, 2.8rem); margin-bottom: .2rem; }
.sheet.end .mini { color: var(--ink2); }
.sheet.end .chips { justify-content: center; margin: .6rem 0 1rem; }
.confetti { width: 140px; height: 50px; display: block; margin: 0 auto .2rem; }

#toasts { position: fixed; inset-inline: 0; top: calc(64px + env(safe-area-inset-top)); display: flex; flex-direction: column; align-items: center; gap: .5rem; z-index: 80; pointer-events: none; padding: 0 .6rem; }
.toast {
  position: relative;
  background: var(--paper); border: var(--bw) solid var(--ink); color: var(--ink);
  padding: .5rem 1rem .4rem; border-radius: 16px; box-shadow: var(--sh-sm);
  font-family: var(--display); font-size: 1.1rem;
  animation: rise .2s cubic-bezier(.3, 1.5, .5, 1);
}
.toast.bad { background: var(--red); }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ===== الجوال والتابلت ===== */
@media (max-width: 1100px) {
  .play { grid-template-columns: minmax(0, 1fr); }
  .boardwrap { position: static; }
  .board { max-height: none; }
  .side { order: 2; gap: .85rem; }
  .feed .log { max-height: 240px; }
  .notes { max-height: 180px; }
  main { padding-bottom: calc(var(--dockh, 150px) + 1.2rem); }

  /* الدوك: النرد والأزرار دايمًا تحت إيدك */
  .dock {
    position: fixed;
    inset-inline: 0;
    bottom: 0;
    z-index: 45;
    padding: .5rem clamp(.5rem, 2.5vw, 1rem) calc(.55rem + env(safe-area-inset-bottom));
    background: linear-gradient(to top, var(--ground) 74%, rgba(59, 29, 143, .86));
    max-height: 60dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-top: 3px solid var(--ink);
    -webkit-overflow-scrolling: touch;
  }
  .dock-in { max-width: 680px; margin: 0 auto; gap: .55rem; }
  .dock .turnbar { padding: .45rem .7rem; }
  .dock .panel { padding: .75rem .85rem; }
  .dock .panel h3 { font-size: 1.15rem; margin-bottom: .35rem; }
  .dock .panel .mini { font-size: .84rem; }
  .boardwrap.near { max-height: 58dvh; }
  .dock { max-height: 52dvh; }
  .dock .tip { position: absolute; inset-inline: .5rem; bottom: calc(100% + 8px); box-shadow: 0 3px 0 var(--ink); z-index: 2; }
  .dock .panel .mini { display: none; }
  .dock .turnbar { padding: .3rem .55rem; }
  .dock .turnbar .av { width: 34px; height: 34px; }
  .dock .tb-main b { font-size: 1.12rem; }
  .dock .tb-main small { font-size: .76rem; }
  .dock .clock { width: 42px; height: 42px; font-size: 1.05rem; }
  .dock .btn.big { min-height: 46px; font-size: 1.12rem; padding: .55rem .9rem .4rem; }
  .dock .panel h3 { font-size: 1.05rem; }
  .dock .row.gap { gap: .45rem; }
  .boardwrap.near .board { width: 190%; }
  .tip { padding: .35rem .45rem .35rem .55rem; gap: .4rem; }
  .tip p { font-size: .82rem; }
  .tip-ico .ico { width: 18px; height: 18px; }
}

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; gap: 1rem; }
  .hero-art-wrap { order: 2; max-height: 34dvh; transform: rotate(1deg); }
  .hero-art { height: 34dvh; max-height: 34dvh; }
  .hero h1 { -webkit-text-stroke-width: 6px; text-shadow: 4px 5px 0 var(--ink); }
  .hero-words { padding: 0; }
  .cta { max-width: none; margin: .9rem 0 .6rem; }
  .boardwrap.near .board { width: 185%; }
}

@media (max-width: 560px) {
  main { padding-bottom: calc(var(--dockh, 150px) + 1rem); }
  .mark-word { font-size: 1.3rem; }
  .bcode { font-size: 2.3rem; }
  .sheet { border-radius: 22px 22px 0 0; padding: 1rem .9rem 1.2rem; }
  .chipbtn { width: 76px; }
  .chipbtn svg { width: 60px; height: 60px; }
  .chip.big svg { width: 80px; height: 80px; }
  .board { filter: drop-shadow(3px 4px 0 var(--ink)); }
  .card-panel:nth-child(1), .card-panel:nth-child(3) { transform: none; }
  .tour-card { border-radius: 20px; box-shadow: 5px 6px 0 var(--ink); }
  .tour-art { width: 62px; height: 62px; }
  .tour-words h3 { font-size: 1.18rem; }
  .tour-words p { font-size: .9rem; }
  .helpgrid { grid-template-columns: 1fr; }
  .bcode { letter-spacing: .12em; }
  .dock .panel .row.gap .btn.big { flex: 1 1 100%; }
  .dock .panel h3 .ico { width: 19px; height: 19px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ===== آيفون: لمس مريح، بدون تكبير تلقائي، وبدون ما يغطي الشق ===== */
html { background-color: var(--ground); }
.board, .boardwrap { -webkit-touch-callout: none; }
.btn, .pickbtn, .chipbtn, .iconbtn { -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
.btn:active, .pickbtn:active, .chipbtn:active, .iconbtn:active { transform: translate(2px, 2px); }
@media (max-width: 560px) {
  .iconbtn, .iconbtn.sm { min-width: 44px; min-height: 44px; }
  .bar .bar-ctx { gap: .3rem; }
  .bar [data-act="share"] { display: none; }
  .bar-in { gap: .5rem; padding-inline: max(.6rem, env(safe-area-inset-left)) max(.6rem, env(safe-area-inset-right)); }
  .mark-word { font-size: 1.15rem; }
  .mark { min-height: 44px; }
  main { padding-inline: max(.8rem, env(safe-area-inset-left)) max(.8rem, env(safe-area-inset-right)); }
  select, .sel select { font-size: 16px; min-height: 44px; }
  .rules summary { min-height: 44px; display: flex; align-items: center; }
  .pickbtn { min-height: 46px; }
  /* زر الإجراء الأساسي يظل ظاهر تحت بالنوافذ الطويلة */
  .sheet > .row.gap:last-child, .sheet > .sheet-actions:last-child {
    position: sticky; bottom: calc(-1.2rem - env(safe-area-inset-bottom));
    background: var(--paper); margin-inline: -.9rem; padding: .6rem .9rem calc(.6rem + env(safe-area-inset-bottom));
    border-top: 3px solid var(--ink); z-index: 2;
  }
  .sheet.end > .row.gap:last-child { background: var(--yel); }
  .sheet .row.gap .btn { flex: 1 1 0; }
}
/* الجوال بالعرض: الدوك ما ياكل الشاشة */
@media (max-height: 500px) and (orientation: landscape) {
  .dock { max-height: 46dvh; }
  .sheet { max-height: 92dvh; }
}
