/* Yams – NajPhil Games */
:root {
  --blue-1: #2f9be6;
  --blue-2: #1677c9;
  --blue-3: #0d5fa8;
  --blue-dark: #0a4a85;
  --ink: #0b4f8a;
  --ink-soft: #3d6f97;
  --sky: #e3f4fd;
  --sky-2: #f4fbff;
  --cell: #bfe4f8;
  --cell-done: #dff1fb;
  --cell-shadow: #7fbde3;
  --board: #3cc4f5;
  --board-alt: #2fb6ec;
  --orange: #f08c00;
  --orange-hi: #ffb43a;
  --orange-lo: #e67e00;
  --orange-shadow: #b85f00;
  --orange-ink: #b35900;
  --danger: #c93a3a;
  --cell-size: 48px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: 'Fredoka', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: radial-gradient(120% 70% at 50% 0%, var(--blue-1) 0%, var(--blue-2) 55%, var(--blue-3) 100%) fixed;
  background-color: var(--blue-2);
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--blue-2); }
a:hover { color: var(--orange-lo); }
button, input, select, textarea { font-family: inherit; font-size: 16px; }
h1, h2, h3 { margin: 0; }

.page {
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 16px 100px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ---------- éléments communs ---------- */
.card, .panel {
  background: var(--sky);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 4px 0 #8cc2e6;
}
.panel.light, .card { background: var(--sky-2); }
.panel h3 { font-size: 18px; color: var(--blue-2); margin-bottom: 8px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.panel-head h3 { margin: 0; }
.page-title { color: #fff; font-size: 28px; text-shadow: 0 3px 0 var(--blue-dark); }
.hello { color: #fff; font-size: 21px; font-weight: 600; }
.on-blue, .on-blue a { color: #e3f4fd; text-align: center; }
.on-blue a:hover { color: #ffe2b0; }
.center { text-align: center; }
.muted { color: var(--ink-soft); }
.small { font-size: 13px; }
.right { align-self: flex-end; }
.grow { flex: 1; min-width: 0; }
.hidden { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border: 0; border-radius: 14px;
  font-weight: 700; font-size: 17px; text-decoration: none; cursor: pointer;
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(3px); }
.btn-orange {
  background: linear-gradient(var(--orange-hi), var(--orange-lo));
  border: 2px solid #ffe6b8; color: #fff; text-shadow: 0 2px 0 #b35c00;
  box-shadow: 0 5px 0 var(--orange-shadow);
}
.btn-orange:hover { color: #fff; filter: brightness(1.05); }
.btn-light { background: linear-gradient(#f6fbff, #cde8f8); color: var(--ink); box-shadow: 0 5px 0 #6fb2de; }
.btn-light:hover { color: var(--ink); }
.btn-white { background: #fff; color: var(--ink-soft); box-shadow: 0 3px 0 #9fcbe6; }
.btn-danger { background: var(--danger); color: #fff; box-shadow: 0 4px 0 #8f2323; }
.btn-danger:hover { color: #fff; }
.btn-big { min-height: 60px; font-size: 21px; width: 100%; border-radius: 16px; }
.btn-sm { min-height: 40px; padding: 0 12px; font-size: 15px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; transform: none; }

.icon-btn {
  width: 48px; height: 48px; flex: none; border: 0; border-radius: 12px; cursor: pointer;
  background: linear-gradient(#fff, #dff1fb); box-shadow: 0 4px 0 #8cc2e6;
  display: inline-flex; align-items: center; justify-content: center; color: var(--orange);
}
.icon-btn:hover { color: var(--orange-lo); }

.avatar {
  width: 40px; height: 40px; flex: none; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 18px;
  background: linear-gradient(#3aa8f0, #0d6fc4);
}
.avatar.sm { width: 34px; height: 34px; font-size: 15px; }
.avatar.seat2 { background: linear-gradient(#ffad3a, #d96d00); }
.avatar.seat3 { background: linear-gradient(#5fd08a, #1f9d55); }
.avatar.seat4 { background: linear-gradient(#c58cf2, #8a46c9); }
.avatar.seat5 { background: linear-gradient(#f27a8c, #c93a52); }
.avatar-btn { border: 3px solid #fff; border-radius: 50%; padding: 0; background: none; cursor: pointer; display: flex; }

.tag-orange { background: var(--orange); color: #fff; font-weight: 700; font-size: 13px; padding: 3px 10px; border-radius: 10px; white-space: nowrap; }

.flash { padding: 10px 14px; border-radius: 12px; font-weight: 600; }
.flash-ok, .ok-box { background: #e6f7ea; color: #1d6b2e; }
.flash-error, .error-box { background: #fde8e8; color: #9b2222; }
.ok-box, .error-box { padding: 10px 12px; border-radius: 12px; margin: 0; }

/* ---------- formulaires ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form h1 { font-size: 22px; color: var(--blue-2); text-align: center; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 14px; font-weight: 600; }
input:not([type=radio]), select, textarea {
  border: 2px solid var(--cell); border-radius: 12px; padding: 0 14px; min-height: 48px;
  font-size: 17px; color: var(--ink); background: #fff; width: 100%;
}
textarea { padding: 10px 14px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--orange-hi); border-color: var(--orange); }
.form-inline { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.code-input { text-transform: uppercase; letter-spacing: 6px; font-size: 26px !important; text-align: center; font-weight: 700; }
.segmented { display: flex; background: var(--cell-done); border-radius: 14px; padding: 4px; gap: 4px; }
.segmented label { flex: 1; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; text-align: center; padding: 11px 6px; border-radius: 11px; font-size: 16px; font-weight: 700; color: var(--blue-2); cursor: pointer; }
.segmented input:checked + span { background: var(--orange); color: #fff; box-shadow: 0 3px 0 var(--orange-shadow); }
.segmented input:focus-visible + span { outline: 3px solid var(--orange-hi); }
#local-form .when-account, #local-form .when-guest { display: flex; flex-direction: column; gap: 12px; }
#local-form:has(input[value=guest]:checked) .when-account { display: none; }
#local-form:has(input[value=account]:checked) .when-guest { display: none; }

/* ---------- pages de connexion ---------- */
body.auth .page { align-items: center; padding-top: 30px; max-width: 440px; }
body.auth .card { width: 100%; }
.logo-big { width: 210px; height: auto; filter: drop-shadow(0 6px 10px rgba(6, 40, 90, .35)); }
.logo-mid { width: 150px; height: auto; filter: drop-shadow(0 6px 10px rgba(6, 40, 90, .35)); }
.logo-small { width: 62px; height: auto; filter: drop-shadow(0 3px 5px rgba(6, 40, 90, .35)); }
.game-title { font-size: 54px; font-weight: 700; color: #fff; letter-spacing: 4px; text-shadow: 0 4px 0 var(--blue-dark); line-height: 1; margin-top: -8px; }
.game-title.small { font-size: 32px; letter-spacing: 2px; margin: 0; text-shadow: 0 3px 0 var(--blue-dark); }

/* ---------- accueil ---------- */
.top { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; }
.notice { display: flex; align-items: center; gap: 10px; background: #fff4e0; color: #7a3e00; border-radius: 14px; padding: 10px 12px; text-decoration: none; box-shadow: 0 3px 0 #e0b170; }
.notice svg { color: var(--orange-lo); flex: none; }
.notice span:nth-child(2) { flex: 1; }
.notice:hover { color: #7a3e00; }
.chips { display: flex; gap: 10px; }
.chip { flex: 1; background: var(--sky); border-radius: 14px; padding: 8px 12px; box-shadow: 0 3px 0 #8cc2e6; display: flex; flex-direction: column; }
.chip span { font-size: 12px; font-weight: 600; color: var(--blue-2); }
.chip b { font-size: 24px; }
.chip.big b { font-size: 28px; line-height: 1.1; }
.chip small { font-size: 12px; color: var(--ink-soft); }
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.menu-buttons { display: flex; flex-direction: column; gap: 14px; }
.menu-buttons form { display: contents; }
.row2 { display: flex; gap: 10px; }
.row2 .btn-big { font-size: 18px; }
.list-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; color: var(--ink); text-decoration: none; }
.list-row.link:hover { color: var(--orange-lo); }
.list-row small { display: block; color: var(--ink-soft); font-size: 13px; }
.list-row + .list-row { border-top: 1px solid #cfe6f3; }
form.inline { display: inline-flex; gap: 6px; margin: 0; }

/* classement */
.toggle { display: flex; background: var(--cell-done); border-radius: 10px; padding: 3px; }
.toggle a { padding: 6px 12px; border-radius: 8px; font-weight: 700; font-size: 14px; color: var(--blue-2); text-decoration: none; }
.toggle a.on { background: var(--orange); color: #fff; }
.rank-head, .rank-row { display: flex; align-items: center; gap: 10px; padding: 7px 6px; }
.rank-head { font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.rank-head span:not(.grow), .rank-row .num, .rank-row .muted { width: 62px; text-align: right; }
.rank-row { border-radius: 12px; }
.rank-row.me { background: #fff1d9; }
.rank-row .rank { width: 22px; font-weight: 700; font-size: 17px; color: var(--ink-soft); }
.rank-row .rank.first { color: var(--orange-lo); }
.rank-row .num { font-weight: 700; font-size: 17px; }

/* messages */
.message.unread { box-shadow: 0 4px 0 var(--orange); }
.msg-body { line-height: 1.5; margin-top: 6px; }

/* admin */
.admin-grid { display: grid; gap: 14px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; font-size: 13px; color: var(--ink-soft); padding: 6px 8px; }
.table td { padding: 8px; border-top: 1px solid #cfe6f3; vertical-align: middle; }
.table .actions { white-space: nowrap; display: flex; gap: 6px; }
.search input { min-height: 40px; }

/* barre de navigation */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  background: var(--sky-2); border-radius: 20px 20px 0 0;
  padding: 8px 0 calc(10px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 14px rgba(6, 50, 100, .2);
}
.bottom-nav a { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; font-weight: 600; color: var(--ink-soft); text-decoration: none; min-width: 60px; }
.bottom-nav a.active { color: var(--orange-lo); }
.bottom-nav .badge { position: absolute; top: -4px; right: 10px; background: var(--danger); color: #fff; font-size: 11px; border-radius: 9px; padding: 1px 6px; }

/* ---------- partie ---------- */
body.game-page .page { max-width: none; padding: 10px 10px 16px; min-height: 100vh; min-height: 100dvh; }
.game { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; max-width: 420px; margin: 0 auto; flex: 1; }
.side-left, .side-right, .board-wrap { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.side-right { flex: 1; justify-content: flex-start; }
.game-top { position: relative; width: 100%; display: flex; align-items: center; gap: 8px; padding-top: 26px; }
.desk-only { display: none; }

.timer {
  position: absolute; top: 0; left: 50%; transform: translateX(-10%);
  background: var(--cell-done); color: #1d7a2e; font-weight: 700; font-size: 15px;
  padding: 2px 14px; border-radius: 12px; box-shadow: 0 2px 0 #9fcbe6;
}
.timer.warn { color: #c0392b; animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: translateX(-10%) scale(1.1); } }

.versus {
  flex: 1; min-width: 0; height: 58px; background: var(--sky-2); border-radius: 30px; box-shadow: 0 4px 0 #8cc2e6;
  display: flex; align-items: center; padding: 0 5px; gap: 4px;
}
.vs { font-size: 14px; font-weight: 700; color: var(--blue-2); }
.vs-player { flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; }
.vs-player.right { flex-direction: row-reverse; }
.vs-player .avatar { width: 46px; height: 46px; font-size: 20px; }
.vs-text { flex: 1; min-width: 0; text-align: center; border-radius: 10px; padding: 2px 0; display: flex; flex-direction: column; }
.vs-player.active .vs-text { background: #cfe3ef; }
.vs-name { font-size: 12px; font-weight: 600; color: #0d6fc4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 2px; }
.vs-player.seat2 .vs-name { color: var(--orange-ink); }
.vs-score { font-size: 22px; font-weight: 700; line-height: 1; }

.board { width: 100%; border-radius: 16px; overflow: hidden; background: var(--board); box-shadow: 0 6px 0 rgba(6, 60, 110, .35); }
.board-head { display: flex; background: var(--sky); font-weight: 700; font-size: 18px; color: var(--blue-2); }
.board-head span { flex: 1; text-align: center; padding: 7px 0; }
.board-row { display: flex; justify-content: space-between; align-items: center; padding: 4px 10px; background: var(--board); }
.board-row.alt { background: var(--board-alt); }
.half { display: flex; gap: 6px; align-items: center; }
.board:not(.two) .half { gap: 10px; }

.tile {
  width: var(--cell-size); height: var(--cell-size); flex: none; border-radius: 11px; border: 2px solid #ffe6b8;
  background: linear-gradient(var(--orange-hi), var(--orange-lo)); box-shadow: 0 3px 0 var(--orange-shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; text-shadow: 0 2px 0 #b35c00;
}
.tile.txt { font-size: 22px; line-height: 1; }
.tile.txt.yams { font-size: 13px; }
.tile.txt.big { font-size: 28px; }
.tile.cards small { font-size: 9px; margin-top: 2px; }
.tile.pips { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px; padding: 8px; }
.pip, .dpip { border-radius: 50%; aspect-ratio: 1; }
.pip.on { background: #fff; }
.dpip.on { background: #123a5c; }

.cell {
  width: var(--cell-size); height: var(--cell-size); flex: none; border-radius: 10px; border: 0;
  background: var(--cell); box-shadow: 0 3px 0 var(--cell-shadow);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 20px; color: var(--ink); padding: 0;
}
.cell.done { background: var(--cell-done); }
.cell.cur:not(.done) { background: #cdeafa; }
.cell.pot { color: var(--orange-ink); font-size: 18px; cursor: pointer; background: #d4effc; }
.cell.pot.zero { color: #6f8fa8; }
.cell.pot:hover { background: #fff; }
.cell.pot.sel { background: #fff; color: var(--orange-lo); border: 3px solid var(--orange); box-shadow: 0 3px 0 var(--orange-shadow); animation: pop .2s; }
@keyframes pop { 50% { transform: scale(1.08); } }

.bonus-label { width: var(--cell-size); text-align: center; color: #fff; font-weight: 700; font-size: 19px; line-height: 1; display: flex; flex-direction: column; }
.bonus-label small { font-size: 12px; }
.bonus-circle { width: var(--cell-size); height: var(--cell-size); flex: none; border-radius: 50%; background: var(--blue-3); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; line-height: 1.05; }
.bonus-circle i { font-style: normal; border-top: 2px solid #fff; padding-top: 1px; }
.bonus-circle.ok { background: #1f9d55; font-size: 16px; }

.hint { margin: 0; min-height: 20px; font-size: 14px; color: #e3f4fd; text-align: center; }
.hint.error { color: #fff; background: rgba(201, 58, 58, .85); border-radius: 10px; padding: 3px 10px; }

.dice { display: flex; gap: 12px; padding-top: 6px; min-height: 66px; align-items: flex-end; }
.die {
  width: 54px; height: 54px; padding: 9px; border-radius: 12px; border: 3px solid transparent;
  background: linear-gradient(#fff, #e9eef2); box-shadow: 0 4px 0 var(--blue-dark);
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; cursor: pointer;
  transition: transform .12s;
}
.die:disabled { cursor: default; }
.die.held { border-color: var(--orange); box-shadow: 0 4px 0 var(--orange-shadow); transform: translateY(-8px); }
.die.empty { background: rgba(6, 50, 100, .45); box-shadow: inset 0 3px 6px rgba(0, 0, 0, .25); border: 0; }
.dice.shaking .die:not(.held) { animation: shake .14s infinite; }
@keyframes shake { 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }

.roll-btn {
  width: 100%; height: 62px; margin-top: auto; border: 0; border-radius: 16px; cursor: pointer;
  background: linear-gradient(#f6fbff, #cde8f8); box-shadow: 0 6px 0 #6fb2de;
  display: flex; align-items: center; justify-content: center; gap: 14px;
  font-size: 30px; font-weight: 700; color: #e07800; letter-spacing: 1px;
}
.roll-btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 #6fb2de; }
.roll-btn:disabled { opacity: .55; cursor: default; }
.roll-count { width: 38px; height: 38px; border-radius: 50%; background: var(--orange); color: #fff; font-size: 22px; display: flex; align-items: center; justify-content: center; letter-spacing: 0; }

/* fenêtres */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(4, 30, 60, .55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { width: 100%; max-width: 400px; background: var(--sky-2); border-radius: 20px; padding: 22px; box-shadow: 0 6px 0 #6fb2de; display: flex; flex-direction: column; gap: 12px; text-align: center; max-height: 90vh; overflow: auto; }
.modal h2 { color: var(--blue-2); font-size: 24px; }
.modal p { margin: 0; }
.modal-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.modal-actions form { display: contents; }
.big-code { font-size: 44px; font-weight: 700; letter-spacing: 8px; color: var(--orange-lo); background: #fff; border-radius: 14px; padding: 8px; box-shadow: 0 3px 0 #9fcbe6; }
.end-sub { font-size: 22px; font-weight: 700; color: var(--orange-lo); }
.end-row { display: flex; align-items: center; gap: 12px; text-align: left; background: #fff; border-radius: 14px; padding: 8px 12px; }
.end-row b { flex: 1; }
.end-score { font-size: 28px; font-weight: 700; }
.detail { width: 100%; border-collapse: collapse; }
.detail th, .detail td { padding: 6px; border-bottom: 1px solid #cfe6f3; }
.detail td:first-child { text-align: left; color: var(--ink-soft); }
.detail .tot td { font-weight: 700; font-size: 18px; color: var(--ink); }
.spinner { width: 34px; height: 34px; margin: 4px auto; border: 4px solid var(--cell); border-top-color: var(--orange); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast { position: fixed; left: 50%; top: 40%; z-index: 60; transform: translate(-50%, -50%) scale(.7); opacity: 0; transition: all .3s; background: linear-gradient(var(--orange-hi), var(--orange-lo)); color: #fff; font-size: 28px; font-weight: 700; padding: 14px 26px; border-radius: 18px; border: 3px solid #ffe6b8; box-shadow: 0 6px 0 var(--orange-shadow); text-shadow: 0 2px 0 #b35c00; pointer-events: none; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* petits écrans */
@media (max-width: 370px) {
  :root { --cell-size: 42px; }
  .die { width: 48px; height: 48px; padding: 8px; }
  .dice { gap: 8px; }
  .vs-player .avatar { width: 38px; height: 38px; }
}

/* ---------- ordinateur ---------- */
@media (min-width: 760px) {
  .page { padding-top: 28px; }
  .admin-grid { grid-template-columns: 1fr 1fr; }
  body:not(.auth):not(.game-page) .page { max-width: 760px; }
  .bottom-nav { left: 50%; right: auto; transform: translateX(-50%); width: 560px; }
}

@media (min-width: 1000px) {
  :root { --cell-size: 58px; }
  body.game-page .page { padding: 28px 36px; }
  .game { flex-direction: row; align-items: flex-start; justify-content: center; max-width: 1280px; gap: 36px; }
  .side-left { width: 300px; flex: none; align-items: stretch; }
  .side-right { width: 300px; flex: none; justify-content: center; align-self: center; gap: 18px; }
  .board-wrap { width: auto; }
  .board { width: auto; }
  .board-row { padding: 6px 16px; }
  .half { gap: 8px; }
  .board:not(.two) .half { gap: 12px; }
  .tile.txt { font-size: 26px; }
  .tile.txt.yams { font-size: 15px; }
  .tile.txt.big { font-size: 34px; }
  .tile.cards small { font-size: 11px; }
  .tile.pips { padding: 10px; gap: 3px; }
  .cell { font-size: 24px; }
  .cell.pot { font-size: 21px; }
  .bonus-label { font-size: 23px; }
  .bonus-circle { font-size: 16px; }
  .desk-only { display: block; }
  .game-top { flex-wrap: wrap; padding-top: 0; gap: 12px; }
  .logo-side { width: 78px; height: auto; filter: drop-shadow(0 3px 5px rgba(6, 40, 90, .35)); }
  .versus { flex: 1 0 100%; order: 5; }
  .timer { position: static; transform: none; margin-left: auto; font-size: 17px; }
  @keyframes pulse { 50% { transform: scale(1.1); } }
  .side-info { background: rgba(255, 255, 255, .14); border-radius: 16px; padding: 14px 16px; color: #e3f4fd; }
  .side-mode { margin: 0 0 8px; font-weight: 700; color: #fff; }
  .side-player { padding: 6px 0; display: flex; flex-direction: column; font-size: 14px; }
  .side-player b { font-size: 17px; color: #fff; }
  .side-player.active b { color: #ffd38a; }
  .dice { flex-wrap: wrap; justify-content: center; gap: 16px; background: rgba(6, 60, 110, .35); border-radius: 20px; padding: 22px; width: 100%; }
  .die { width: 72px; height: 72px; padding: 12px; border-radius: 15px; gap: 4px; }
  .roll-btn { height: 72px; font-size: 34px; margin-top: 0; }
  .hint { font-size: 15px; order: 3; }
}
