/* ====== БАЗА ====== */
:root{
  --bg:#0b1220;
  --text:#e5e7eb;
  --muted:#94a3b8;
  --card:#111827;
  --line:#253041;
  --accent:#22c55e;
  --danger:#ef4444;
  --warn:#f59e0b;
  --x:#60a5fa;
  --o:#f472b6;
  --navbar-height:70px;
}

*{box-sizing:border-box}
html,body{min-height:100%}
body{
  margin:0;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,'Helvetica Neue',Arial,'Noto Sans',sans-serif;
  background:var(--bg);
  color:var(--text);
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  min-height:100vh;
  display:flex;
  flex-direction:column;
}

#app{
  flex:1;
  width:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:calc(8px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) calc(var(--navbar-height) + 8px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
}

/* ====== КАРТОЧКА И ШАПКИ ИГРОКОВ ====== */
.wrap{
  width:100%;
  max-width:520px;
  margin:0 auto;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:6px;
}
.card{
  width:100%;
  background:var(--card);
  border:1px solid var(--line);
  border-radius:20px;
  padding:14px 14px 16px;
  box-shadow:0 10px 30px rgba(0,0,0,.35);
  display:flex;
  flex-direction:column;
  gap:8px;
}

.badges{
  display:grid;
  grid-template-columns:repeat(2, minmax(0, 1fr));
  gap:10px;
  align-items:stretch;
  width:100%;
}
.badge{
  display:flex;
  align-items:center;
  gap:8px;
  padding:8px 10px;
  background:rgba(255,255,255,.03);
  border:1px solid var(--line);
  border-radius:12px;
  min-width:0;
  flex:1 1 160px;
}
.badge .info{display:flex;align-items:center;gap:8px;min-width:0}
.badge .ava{width:26px;height:26px;border-radius:50%;object-fit:cover;border:1px solid var(--line);background:#0a0e1a}
.badge .text{display:flex;flex-direction:column;gap:1px;min-width:0}
.badge .name{
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
  color:var(--text);opacity:1;
  font-weight:600;
  font-size:14px;
}
.badge .username{
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
  color:var(--muted);
  font-size:11px;
  opacity:.85;
}
#oppBadge{
  flex-direction:row-reverse;
  text-align:right;
}
#oppBadge .info{
  flex-direction:row-reverse;
}
#oppBadge .text{
  align-items:flex-end;
  text-align:right;
}
/* ярче маркеры X/O */
.mark{
  font-weight:800;
  letter-spacing:.4px;
  padding:3px 10px;
  border-radius:10px;
  border:1px solid transparent;
  font-size:14px;
  line-height:1.15;
  box-shadow:inset 0 0 0 1px rgba(255,255,255,.04);
}
.mark.x{
  color:var(--x);
  background:linear-gradient(180deg, rgba(96,165,250,.22), rgba(96,165,250,.10));
  border-color:rgba(96,165,250,.35);
  text-shadow:0 0 10px rgba(96,165,250,.35);
}
.mark.o{
  color:var(--o);
  background:linear-gradient(180deg, rgba(244,114,182,.22), rgba(244,114,182,.10));
  border-color:rgba(244,114,182,.38);
  text-shadow:0 0 10px rgba(244,114,182,.35);
}

/* ====== СТРОКА СТАТУСА ====== */
.status-line{
  margin:0;
  text-align:center;
  font-weight:700;
  color:var(--text);
  opacity:.95;
  font-size:14px;
}
.blink{animation:blink 1s linear infinite}
@keyframes blink{50%{opacity:.5}}

/* ====== ДОСКА 3×3 ====== */
.board{
  width:100%;
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:10px;
}
.cell{
  aspect-ratio:1/1;
  background:#0e1726;
  border:1px solid var(--line);
  border-radius:14px;
  font-size:clamp(32px, 9vw, 48px);
  font-weight:900;
  color:var(--text);
  display:flex;align-items:center;justify-content:center;
  cursor:pointer;
  transition:transform .12s ease, background .2s ease, border-color .2s ease, box-shadow .2s ease;
  box-shadow:inset 0 0 0 1px rgba(255,255,255,.02);
}
.cell:hover{transform:translateY(-1px);border-color:#2f3c52}
.cell:active{transform:translateY(0)}
.cell.disabled{opacity:.55;cursor:not-allowed}
.cell.x{
  color:var(--x);
  background:rgba(96,165,250,.14);
  border-color:rgba(96,165,250,.38);
  box-shadow:inset 0 0 0 1px rgba(96,165,250,.18);
}
.cell.o{
  color:var(--o);
  background:rgba(244,114,182,.14);
  border-color:rgba(244,114,182,.36);
  box-shadow:inset 0 0 0 1px rgba(244,114,182,.18);
}
.cell.win{outline:2px solid var(--accent);box-shadow:0 0 0 3px rgba(34,197,94,.25)}

/* эффект ховера */
.cell{position:relative;overflow:hidden}
.cell::before{
  content:'';
  position:absolute;top:50%;left:50%;
  width:0;height:0;border-radius:50%;
  background:radial-gradient(circle, rgba(34,197,94,.18) 0%, transparent 70%);
  transform:translate(-50%,-50%);
  transition:all .3s ease;
}
.cell:hover::before{width:min(120px, 90%);height:min(120px, 90%)}

/* ====== НАВБАР ВНИЗУ ====== */
.navbar{
  position:fixed;
  left:50%;
  transform:translateX(-50%);
  bottom:calc(8px + env(safe-area-inset-bottom));
  width:calc(100% - 16px - env(safe-area-inset-left) - env(safe-area-inset-right));
  max-width:480px;
  padding:8px;
  backdrop-filter:blur(20px);
  background:rgba(15,23,42,.85);
  border:1px solid var(--line);
  border-radius:20px;
  min-height:var(--navbar-height);
  display:flex;
  gap:8px;
  justify-content:space-between;
  align-items:center;
  box-shadow:0 10px 30px rgba(0,0,0,.4);
  z-index:900;
}
.navbtn{
  flex:1;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:2px;
  background:rgba(255,255,255,.03);
  border:1px solid var(--line);
  border-radius:14px;
  padding:6px 8px;
  cursor:pointer;
  transition:transform .12s ease, background .2s ease, border-color .2s ease, box-shadow .2s ease;
  min-width:0;
}
.navbtn:active{transform:scale(.98)}
.navbtn.active,.navbtn.is-waiting{background:rgba(34,197,94,.12);border-color:#365b43;box-shadow:0 0 0 1px rgba(34,197,94,.15)}

/* иконки */
.navbtn .sym{
  width:52px;
  height:52px;
  display:flex;
  align-items:center;
  justify-content:center;
}
.icon{
  width:36px;
  height:36px;
  display:block;
}
.icon-lg{
  width:44px;
  height:44px;
}
.navbtn .label{
  font-size:10px;
  color:var(--muted);
  text-align:center;
  font-weight:500;
  line-height:1.05;
  margin-top:0;
}

/* ====== АВТОР ====== */
.author-badge{
  position: sticky;
  top: calc(8px + env(safe-area-inset-top));
  left: auto;
  bottom: auto;
  transform:none;
  align-self:flex-start;
  margin:0 0 6px 2px;
  z-index:2;

  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:6px 12px;
  border-radius:999px;
  border:1px solid var(--line);
  background:rgba(17,24,39,.95);
  backdrop-filter:blur(10px);
  color:var(--muted);
  font-size:11px;
  cursor:pointer;
  transition:background .2s ease,border-color .2s ease,transform .12s ease, box-shadow .2s ease;
  box-shadow:0 4px 12px rgba(0,0,0,.25);
  order:-1;
}
.author-badge:hover{
  background:rgba(30,41,59,.95);
  border-color:#324055;
  box-shadow:0 6px 16px rgba(0,0,0,.3);
}
.author-badge:active{transform:none}
.author-badge img{
  width:22px;
  height:22px;
  border-radius:50%;
  object-fit:cover;
  border:1px solid var(--line);
}
.author-badge span{
  font-weight:600;
  color:var(--text);
  opacity:.85;
}
.author-badge small{
  color:var(--muted);
  font-weight:500;
}

/* ====== МОДАЛКА ====== */
.modal{
  position:fixed;
  inset:0;
  display:none;
  align-items:center;
  justify-content:center;
  z-index:1000;
  background:rgba(0,0,0,.5);
  backdrop-filter:blur(4px);
}
.modal.show{display:flex}
.modal .box{
  width:min(92vw,460px);
  background:var(--card);
  border:1px solid var(--line);
  border-radius:20px;
  padding:20px;
  color:var(--text);
  animation:slideInUp .25s ease;
  box-shadow:0 20px 60px rgba(0,0,0,.5);
}
.modal h3{
  margin:0 0 12px;
  font-size:20px;
  font-weight:800;
}
.modal .body{
  margin:0 0 16px;
  color:var(--muted);
  max-height:60vh;
  overflow-y:auto;
  display:flex;
  flex-direction:column;
  gap:12px;
}
.modal .body:empty{display:none}
.modal .body p{margin:0;color:var(--muted)}
.modal .body .modal-text{line-height:1.5;color:var(--text)}
.modal .body .modal-phrase{line-height:1.4;color:var(--text);opacity:.88;font-size:14px}

/* кнопки модалки */
.modal .row{
  display:flex;
  gap:10px;
  justify-content:center;
  flex-wrap:wrap;
}
.btn{
  border:1px solid var(--line);
  background:#1e293b;
  color:var(--text);
  padding:12px 24px;
  border-radius:12px;
  cursor:pointer;
  font-weight:600;
  font-size:14px;
  transition:all .2s ease;
  min-width:100px;
  flex:1;
  max-width:200px;
}
.btn:hover{
  background:#2d3748;
  border-color:#3d4a5c;
  transform:translateY(-1px);
  box-shadow:0 4px 12px rgba(0,0,0,.3);
}
.btn:active{transform:translateY(0)}
.btn.primary{
  background:var(--accent);
  border-color:#1c7b44;
  color:#08140e;
  font-weight:700;
}
.btn.primary:hover{
  background:#2ecc71;
  border-color:#25a85a;
  box-shadow:0 4px 16px rgba(34,197,94,.4);
}
.btn.danger{
  background:var(--danger);
  border-color:#c53030;
  color:#fff;
}
.btn.danger:hover{
  background:#f56565;
  border-color:#dc2626;
}

.achievements-section{display:flex;flex-direction:column;gap:10px}
.achievements-header{display:flex;align-items:center;justify-content:space-between}
.achievements-title{font-weight:700;font-size:15px}
.achievements-counter{font-size:12px;color:var(--muted)}
.achievements-empty{padding:12px;border:1px dashed var(--line);border-radius:10px;font-size:13px;color:var(--muted);text-align:center}
.achievements-grid{display:flex;flex-direction:column;gap:10px}
.achievement-card{display:flex;gap:12px;padding:12px;border:1px solid var(--line);border-radius:14px;background:rgba(15,23,42,.7);transition:border-color .2s ease,transform .2s ease}
.achievement-card:hover{transform:translateY(-1px)}
.achievement-card--unlocked{border-color:rgba(34,197,94,.6);box-shadow:0 0 0 1px rgba(34,197,94,.2)}
.achievement-frame{width:64px;height:64px;border:2px dashed var(--line);border-radius:16px;display:flex;align-items:center;justify-content:center;background:rgba(10,14,26,.85);overflow:hidden;flex-shrink:0;position:relative}
.achievement-frame::after{content:"";position:absolute;inset:0;border-radius:14px;pointer-events:none;box-shadow:inset 0 0 0 1px rgba(255,255,255,.05)}
.achievement-frame--emerald{border-color:rgba(16,185,129,.6);box-shadow:0 0 12px rgba(16,185,129,.15)}
.achievement-frame--blue{border-color:rgba(59,130,246,.55);box-shadow:0 0 12px rgba(59,130,246,.15)}
.achievement-frame--violet{border-color:rgba(139,92,246,.55);box-shadow:0 0 12px rgba(139,92,246,.18)}
.achievement-frame--amber{border-color:rgba(245,158,11,.6);box-shadow:0 0 12px rgba(245,158,11,.2)}
.achievement-frame--rose{border-color:rgba(244,63,94,.6);box-shadow:0 0 12px rgba(244,63,94,.18)}
.achievement-frame--sky{border-color:rgba(14,165,233,.6);box-shadow:0 0 12px rgba(14,165,233,.18)}
.achievement-frame--indigo{border-color:rgba(99,102,241,.6);box-shadow:0 0 12px rgba(99,102,241,.18)}
.achievement-frame--teal{border-color:rgba(20,184,166,.6);box-shadow:0 0 12px rgba(20,184,166,.18)}
.achievement-icon{font-size:28px;line-height:1;filter:drop-shadow(0 2px 4px rgba(0,0,0,.35))}
.achievement-image{width:100%;height:100%;object-fit:cover}
.achievement-body{flex:1;display:flex;flex-direction:column;gap:6px}
.achievement-row{display:flex;justify-content:space-between;align-items:center;gap:12px}
.achievement-name{font-weight:700;font-size:15px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.achievement-status{font-size:12px;color:var(--muted)}
.achievement-card--unlocked .achievement-status{color:var(--accent);font-weight:600}
.achievement-description{font-size:13px;color:var(--muted);line-height:1.3}
.achievement-progress{display:flex;flex-direction:column;gap:6px}
.achievement-progress-bar{position:relative;height:8px;border-radius:999px;background:rgba(148,163,184,.2);overflow:hidden}
.achievement-progress-fill{position:absolute;left:0;top:0;bottom:0;background:linear-gradient(90deg, rgba(34,197,94,.85), rgba(74,222,128,.85));border-radius:999px;transition:width .3s ease}
.achievement-progress-text{font-size:12px;color:var(--muted);font-weight:600}
.achievement-card--unlocked .achievement-progress-fill{background:linear-gradient(90deg, rgba(34,197,94,1), rgba(74,222,128,1))}
.achievement-hint{font-size:11px;color:var(--warn)}

/* ====== НОТИФИКАЦИИ ====== */
#notification-container{position:fixed;top:20px;right:20px;z-index:1100;pointer-events:none}
.notification{
  background:var(--card);border:1px solid var(--line);
  border-radius:12px;padding:12px 14px;max-width:320px;
  transform:translateX(100%);transition:transform .25s ease; margin-top:10px;
}
.notification.show{transform:translateX(0)}
.notification .notification-content{display:flex;align-items:center;gap:8px}
.notification .notification-message{flex:1}
.notification .notification-close{pointer-events:auto;background:transparent;border:0;color:var(--muted);font-size:18px;cursor:pointer}
.notification.success{border-left:4px solid var(--accent)}
.notification.error{border-left:4px solid var(--danger)}
.notification.warning{border-left:4px solid var(--warn)}

/* ====== ДОП. АНИМАЦИИ ====== */
@keyframes slideInUp { 
  from { 
    transform:translateY(20px);
    opacity:0;
  } 
  to { 
    transform:none;
    opacity:1;
  } 
}

/* ====== АДАПТИВ ====== */
@media (max-width:520px){
  :root{ --navbar-height:68px; }
  .card{padding:12px 12px 14px;}
  .board{gap:8px;}
  .navbtn{padding:5px 7px;}
  .navbtn .sym{width:48px;height:48px;}
  .icon{width:34px;height:34px;}
  .icon-lg{width:40px;height:40px;}
}

@media (max-width:400px){
  :root{ --navbar-height:88px; }
  .badges{grid-template-columns:1fr;}
  .badge{flex:1 1 100%;}
  .badge .name{max-width:100%;}
  #oppBadge{flex-direction:row;text-align:left;}
  #oppBadge .info{flex-direction:row;}
  #oppBadge .text{align-items:flex-start;text-align:left;}
  .navbar{gap:10px;}
}

@media (max-height:700px){
  :root{ --navbar-height:64px; }
  #app{padding-top:calc(6px + env(safe-area-inset-top));}
  .card{padding:10px 10px 12px;}
  .wrap{gap:6px;}
}

@media (max-height:600px){
  :root{ --navbar-height:60px; }
  .board{gap:6px;}
  .cell{border-radius:10px;}
  .author-badge{padding:4px 10px;}
}
