:root {
  --bg-gradient: radial-gradient(circle at top center, #2b2d42, #1a1b2e);
  --panel-bg: rgba(255, 255, 255, 0.08);
  --panel-border: rgba(255, 255, 255, 0.1);
  --panel-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
  
  --primary: #ff9f1c; 
  --secondary: #2ec4b6; 
  --accent: #ff006e; 
  --success: #06d6a0;
  --danger: #ef476f;
  
  --text-main: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.7);
  
  --font-main: 'Outfit', sans-serif;
  --font-display: 'Permanent Marker', cursive;
  
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; user-select: none; }

body {
  margin: 0;
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-main);
  font-family: var(--font-main);
  overflow: hidden;
  height: 100vh;
}


.bg-animation {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.4;
  animation: floatBlob 10s infinite alternate;
}
.blob-1 { width: 400px; height: 400px; background: var(--accent); top: -100px; left: -100px; }
.blob-2 { width: 300px; height: 300px; background: var(--secondary); bottom: -50px; right: -50px; animation-delay: -5s; }
.blob-3 { width: 200px; height: 200px; background: var(--primary); top: 40%; left: 50%; transform: translate(-50%, -50%); animation-duration: 15s; }

@keyframes floatBlob {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(30px, 50px) scale(1.1); }
}

.hidden { display: none !important; }


#game-splash {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  background: #111;
}
.splash-content { text-align: center; animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.game-logo-intro { width: 140px; margin-bottom: 20px; filter: drop-shadow(0 0 15px rgba(255,255,255,0.2)); }
.splash-title {
  font-family: var(--font-display); font-size: 50px; margin: 0;
  background: linear-gradient(45deg, var(--primary), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.loader-container {
  width: 280px; height: 8px; background: rgba(255,255,255,0.1);
  border-radius: 10px; margin: 25px auto 15px; overflow: hidden;
}
.loader-bar {
  height: 100%; width: 0%; background: linear-gradient(90deg, var(--primary), var(--accent));
  box-shadow: 0 0 15px var(--primary); transition: width 0.1s linear;
}
.intro-text { font-size: 20px; font-weight: 800; color: #fff; margin: 0; }
.intro-subtext { font-size: 14px; color: var(--text-muted); margin-top: 5px; }


#main-menu, #lobby-screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}

.btn-settings { background: #4a4e69; color: #fff; }
.btn-settings:hover { background: #5c6185; }

#settings-overlay {
  position: fixed; inset: 0; z-index: 2100; 
  display: flex; align-items: center; justify-content: center;
}

.settings-card {
  width: 400px;
  background: rgba(30, 30, 45, 0.95);
  border: 1px solid rgba(255,255,255,0.15);
  position: relative; z-index: 2;
}

.setting-row { margin-bottom: 20px; text-align: left; }

.setting-label {
  display: flex; justify-content: space-between;
  color: #ccc; font-weight: 700; font-size: 14px; margin-bottom: 10px;
}
.setting-label span:last-child { color: var(--primary); }


input[type=range] {
  -webkit-appearance: none; width: 100%; background: transparent; cursor: pointer;
  appearance: none;
}
input[type=range]:focus { outline: none; }


input[type=range]::-webkit-slider-runnable-track {
  width: 100%; height: 8px; cursor: pointer;
  background: rgba(255,255,255,0.1); border-radius: 4px;
}
input[type=range]::-moz-range-track {
  width: 100%; height: 8px; cursor: pointer;
  background: rgba(255,255,255,0.1); border-radius: 4px;
}


input[type=range]::-webkit-slider-thumb {
  height: 20px; width: 20px; border-radius: 50%;
  background: var(--primary); border: 2px solid #fff;
  -webkit-appearance: none; margin-top: -6px; 
  box-shadow: 0 0 10px rgba(0,0,0,0.5); transition: transform 0.1s;
}
input[type=range]::-moz-range-thumb {
  height: 20px; width: 20px; border-radius: 50%;
  background: var(--primary); border: 2px solid #fff;
  box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

input[type=range]:active::-webkit-slider-thumb { transform: scale(1.2); }

.menu-card {
  background: rgba(30, 30, 45, 0.75);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  padding: 40px; border-radius: 30px;
  text-align: center; width: 480px; max-width: 100%;
}
.lobby-card { width: 900px; max-width: 95vw; }
.panel-animate { animation: panelUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) both; }

.game-title {
  font-family: var(--font-display); font-size: 72px; margin: 0 0 30px;
  text-shadow: 4px 4px 0px rgba(0,0,0,0.3);
  background: linear-gradient(to right, #fff, #ddd);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.game-title span { color: var(--primary); -webkit-text-fill-color: var(--primary); }

.input-group { margin-bottom: 25px; text-align: left; }
.input-group label { display: block; font-size: 12px; font-weight: 800; color: var(--text-muted); margin-bottom: 8px; letter-spacing: 1px; }
input[type="text"] {
  width: 100%; background: rgba(0,0,0,0.3); border: 2px solid rgba(255,255,255,0.1);
  padding: 16px; color: #fff; font-size: 18px; border-radius: var(--radius-sm);
  font-family: var(--font-main); transition: 0.2s;
}
input[type="text"]:focus { border-color: var(--primary); outline: none; background: rgba(0,0,0,0.5); }

.error-msg { color: var(--danger); font-size: 13px; display: none; margin-top: 8px; font-weight: 700; background: rgba(239, 71, 111, 0.1); padding: 5px 10px; border-radius: 6px; }


.menu-buttons { display: flex; flex-direction: column; gap: 12px; }
.menu-btn {
  padding: 18px; border: none; border-radius: var(--radius-sm);
  font-weight: 800; cursor: pointer; font-size: 18px;
  position: relative; transition: transform 0.1s, filter 0.2s;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.menu-btn:active { transform: translateY(2px); box-shadow: 0 3px 10px rgba(0,0,0,0.18); }
.menu-btn:hover { filter: brightness(1.05); }

.btn-create { background: var(--primary); color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.btn-join { background: var(--secondary); color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.btn-join-confirm { background: var(--success); color: #fff; }
.btn-back { background: rgba(255,255,255,0.1); color: #fff; }
.btn-start { background: rgba(6, 214, 160, 0.85); color: #071b15; font-size: 20px; border: 1px solid rgba(6,214,160,0.35); }
.btn-leave { background: rgba(239, 71, 111, 0.15); color: var(--danger); border: 1px solid rgba(239, 71, 111, 0.3); }
.btn-exit { background: #333; color: #aaa; font-size: 14px; padding: 12px; }



.btn-waiting { background: #444 !important; color: #888 !important; cursor: not-allowed; transform: none !important; box-shadow: none !important; }


.lobby-header {
  display: flex; justify-content: space-between; align-items: center;
  background: rgba(0,0,0,0.2); padding: 15px 25px; border-radius: var(--radius-md); margin-bottom: 25px;
  border: 1px solid rgba(255,255,255,0.05);
}
.lobby-info .label { display: block; font-size: 11px; opacity: 0.6; font-weight: bold; }
.lobby-id { font-size: 32px; font-weight: 900; letter-spacing: 4px; color: var(--primary); margin: 0; font-family: monospace; }
.copy-btn {
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); color: #fff;
  padding: 10px 16px; border-radius: 8px; font-weight: 700; cursor: pointer; transition: 0.2s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.copy-btn:hover { background: rgba(255,255,255,0.2); }
.copy-btn.success { background: var(--success); border-color: var(--success); }

.lobby-actions{ display:flex; gap:10px; align-items:center; }
.lobby-settings-btn{ white-space: nowrap; }


.lobby-actions .btn-ico{ font-size: 16px; line-height: 1; }
.lobby-actions .btn-text{ white-space: nowrap; }
.header-actions{ display:flex; gap:10px; align-items:center; }
.header-btn{
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color:#fff;
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 800;
  cursor: pointer;
  transition: 0.2s;
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
}
.header-btn:hover{ background: rgba(255,255,255,0.12); }
.header-btn-settings{ width: 44px; display:flex; justify-content:center; }
.header-btn-leave{
  background: rgba(239, 71, 111, 0.12);
  border-color: rgba(239, 71, 111, 0.25);
  color: var(--danger);
}
.header-btn-leave:hover{ background: rgba(239, 71, 111, 0.18); }

/* Leave button: icon + text (text collapses on small screens) */
.header-btn-leave .leave-ico{ font-size: 16px; line-height: 1; }
.header-btn-leave .leave-text{ white-space: nowrap; }

@media (max-width: 900px) {
  .header-actions{ width: 100%; justify-content: center; 
}
  .header-btn-leave{ flex: 1; }
}

@media (max-width: 520px){
  .header-btn-leave{ padding: 10px 12px; width: 44px; justify-content:center; }
  .header-btn-leave .leave-text{ display:none; }

  /* Lobby header: copy/settings buttons become icon-only on small screens */
  .lobby-actions{ gap: 8px; }
  .lobby-actions .lobby-settings-btn .btn-text{ display:none; }
  .lobby-actions .copy-btn{ padding: 10px 12px; width: 44px; gap: 0; }
  .lobby-header{ padding: 14px 16px; }
}



.lobby-body { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 25px; }

.lobby-footer{
  display:flex;
  gap:12px;
  align-items:center;
  justify-content:space-between;
}
.lobby-footer .menu-btn{ flex:1; }
.lobby-footer .btn-leave{
  flex:0.9;
}

@media (max-width: 900px) {
  .lobby-footer{ flex-direction: column; }
  .lobby-footer .menu-btn{ width:100%; }
}
.section-box {
  background: rgba(0,0,0,0.2); padding: 20px; border-radius: var(--radius-md); text-align: left;
  border: 1px solid rgba(255,255,255,0.05);
}
.section-box h3 { margin: 0 0 15px; font-size: 14px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }

.player-list { height: 220px; overflow-y: auto; padding-right: 5px; }
.player-item {
  padding: 12px; background: rgba(255,255,255,0.05); border-radius: 8px; margin-bottom: 8px;
  display: flex; justify-content: space-between; align-items: center; font-weight: 600;
}
.player-item.is-host { border: 1px solid var(--primary); background: rgba(255, 159, 28, 0.1); }
.player-item.is-host::after { content: '👑 HOST'; font-size: 10px; background: var(--primary); color: #000; padding: 3px 6px; border-radius: 4px; font-weight: 800; }

.round-options { display: flex; gap: 8px; flex-wrap: wrap; }
.round-btn {
  flex: 1; background: rgba(255,255,255,0.05); border: 1px solid transparent; color: #fff;
  padding: 10px; border-radius: 8px; cursor: pointer; font-weight: 700; transition: 0.2s;
}
.round-btn:hover { background: rgba(255,255,255,0.1); }
.round-btn.active { background: var(--primary); color: #000; box-shadow: 0 4px 10px rgba(255, 159, 28, 0.3); transform: scale(1.05); }
.setting-hint { font-size: 12px; color: rgba(255,255,255,0.3); margin-top: 10px; font-style: italic; }


#game-screen { background: #13141f; display: flex; flex-direction: column; }
.game-ui { display: flex; flex-direction: column; height: 100vh; padding: 15px; gap: 15px; max-width: 1600px; margin: 0 auto; width: 100%; }

/* iOS/Android notch & dynamic island safe-area support */
@supports (padding: env(safe-area-inset-top)) {
  .game-ui{
    padding-top: calc(15px + env(safe-area-inset-top));
    padding-left: calc(15px + env(safe-area-inset-left));
    padding-right: calc(15px + env(safe-area-inset-right));
    padding-bottom: calc(15px + env(safe-area-inset-bottom));
  }
}



.header-bar {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; align-items: center;
  background: #1e1e2d; padding: 10px 20px; border-radius: var(--radius-md);
  box-shadow: 0 4px 20px rgba(0,0,0,0.2); border-bottom: 2px solid rgba(255,255,255,0.05);
}
.h-group { display: flex; flex-direction: column; align-items: center; min-width: 80px; }
.h-label { font-size: 10px; color: var(--text-muted); font-weight: 800; letter-spacing: 1px; margin-bottom: 2px; }
.h-val { font-size: 20px; font-weight: 800; color: #fff; }
.word-box { 
  background: var(--panel-bg); padding: 5px 20px; border-radius: 8px; 
  border: 1px solid var(--secondary); color: var(--secondary); letter-spacing: 2px;
}
#game-timer { color: var(--primary); font-size: 24px; font-family: monospace; }


.game-layout { display: flex; flex: 1; gap: 15px; overflow: hidden; min-height: 0; }
.side-panel {
  width: 280px; background: #1e1e2d; border-radius: var(--radius-md);
  display: flex; flex-direction: column; padding: 15px; overflow: hidden;
  border: 1px solid rgba(255,255,255,0.05);
}
.panel-head { font-size: 14px; color: var(--text-muted); margin: 0 0 15px; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 10px; }


.canvas-wrapper {
  flex: 1; min-width: 0; position: relative;
  background: #e0e5ec; /* Kağıt rengi */
  border-radius: var(--radius-md);
  box-shadow: inset 0 0 20px rgba(0,0,0,0.1);
  overflow: hidden; cursor: crosshair;
  border: 8px solid #1e1e2d; /* Çerçeve */
}
canvas { width: 100%; height: 100%; display: block; touch-action: none; }


.tools-area { margin-bottom: 15px; background: rgba(0,0,0,0.2); padding: 12px; border-radius: 12px; }
.tools-row { margin-bottom: 12px; }
.color-palette { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.color-dot {
  width: 100%; aspect-ratio: 1; border-radius: 50%; border: 2px solid rgba(0,0,0,0.2); cursor: pointer; transition: transform 0.1s;
}
.color-dot:hover { transform: scale(1.1); }
.color-dot.active { transform: scale(1.2); border-color: #fff; box-shadow: 0 0 10px rgba(0,0,0,0.5); }

.slider-row { display: flex; flex-direction: column; gap: 5px; }
input[type=range] { width: 100%; accent-color: var(--primary); }

.tools-actions { display: flex; gap: 8px; }
.tool-btn {
  flex: 1; padding: 10px; border-radius: 8px; border: none; background: #2b2d42; color: #fff;
  font-size: 12px; font-weight: 700; cursor: pointer; transition: 0.2s;
  box-shadow: 0 3px 0 rgba(0,0,0,0.3);
}
.tool-btn:active { transform: translateY(3px); box-shadow: none; }
.tool-btn.active { background: var(--primary); color: #000; box-shadow: 0 3px 0 #c4750e; }
.tool-btn.danger { background: #3a1d24; color: var(--danger); }
.tool-btn.danger:hover { background: var(--danger); color: #fff; }

.tools-hint { font-size: 11px; text-align: center; color: rgba(255,255,255,0.4); }


.sab-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.sab-grid button {
  background: #2b2d42; border: 1px solid rgba(255,255,255,0.1); border-radius: 8px; padding: 8px;
  display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; transition: 0.2s;
}
.sab-grid button:not(:disabled):hover { background: rgba(255, 255, 255, 0.1); transform: translateY(-2px); }
.sab-grid button:disabled { opacity: 0.4; cursor: not-allowed; filter: grayscale(1); }
.sab-grid button.sab-disabled-score { opacity: 0.25; filter: grayscale(1) blur(0.2px); }
.sab-icon { font-size: 20px; }
.sab-name { font-size: 10px; font-weight: 700; }
.sab-cost { font-size: 9px; color: var(--primary); }


.chat-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; gap: 10px; }
#chat-box {
  flex: 1; overflow-y: auto; background: rgba(0,0,0,0.2); border-radius: 8px; padding: 10px;
  font-size: 13px; display: flex; flex-direction: column; gap: 6px;
}
#chat-box div { padding: 6px 10px; border-radius: 6px; background: rgba(255,255,255,0.05); line-height: 1.4; }
#chat-box div b { color: var(--secondary); margin-right: 5px; }


#scoreboard-list { overflow-y: auto; padding-right: 5px; }
.score-entry {
  display: flex; justify-content: space-between; padding: 10px;
  background: rgba(255,255,255,0.03); border-radius: 8px; margin-bottom: 6px; font-size: 14px;
  border-left: 3px solid transparent;
}
.score-entry:nth-child(1) { border-left-color: #ffd700; background: linear-gradient(90deg, rgba(255,215,0,0.1), transparent); }
.score-entry:nth-child(2) { border-left-color: #c0c0c0; }
.score-entry:nth-child(3) { border-left-color: #cd7f32; }


.overlay-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.8); backdrop-filter: blur(8px); }

/* Overlays must always sit above canvas and side-panels */
#scene-loading,
#game-intro,
#turn-overlay,
#exit-overlay,
#leavegame-overlay {
  position: fixed;
  inset: 0;
  z-index: 1600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-card, .turn-card, .confirm-card {
  position: relative; z-index: 2; background: #1e1e2d; padding: 30px; border-radius: 20px;
  text-align: center; border: 1px solid rgba(255,255,255,0.1); box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.loading-title { color: var(--primary); font-size: 24px; font-weight: 900; }
.scene-loading-dots span {
  display: inline-block; width: 12px; height: 12px; background: var(--secondary); border-radius: 50%;
  margin: 0 4px; animation: bounceDot 1s infinite;
}
.scene-loading-dots span:nth-child(2) { animation-delay: 0.1s; }
.scene-loading-dots span:nth-child(3) { animation-delay: 0.2s; }

#game-intro h1 { position: relative; z-index: 2; font-size: 60px; color: #fff; margin-bottom: 10px; font-family: var(--font-display); }
#timer-num { position: relative; z-index: 2; font-size: 180px; font-weight: 900; color: var(--primary); text-shadow: 0 10px 30px rgba(255, 159, 28, 0.4); }

#turn-overlay-title { font-size: 30px; font-weight: 900; color: var(--secondary); margin-bottom: 10px; }
#turn-overlay-count { font-size: 100px; font-weight: 900; color: #fff; line-height: 1; }

.warn-title { color: var(--danger); font-size: 24px; margin-bottom: 10px; }
.confirm-text { color: #ccc; margin-bottom: 25px; font-size: 16px; }


#podium-screen { position: fixed; inset: 0; background: radial-gradient(circle, #2b2d42, #000); z-index: 1500; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.podium-container { display: flex; align-items: flex-end; gap: 20px; height: 400px; margin-bottom: 40px; }
.step {
  width: 120px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  color: #111; font-weight: 900; border-radius: 15px 15px 0 0; padding-bottom: 20px; position: relative;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.gold { height: 320px; background: linear-gradient(to bottom, #ffd700, #ffaa00); z-index: 2; order: 2; }
.silver { height: 240px; background: linear-gradient(to bottom, #e0e0e0, #a0a0a0); order: 1; }
.bronze { height: 180px; background: linear-gradient(to bottom, #cd7f32, #a05a2c); order: 3; }

.medal { font-size: 50px; margin-bottom: 10px; }
.crown { position: absolute; top: -60px; font-size: 60px; animation: floatBlob 2s infinite ease-in-out; }
.rank-avatar { width: 50px; height: 50px; background: rgba(0,0,0,0.2); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 24px; margin-bottom: 10px; }
.step p { margin: 0; font-size: 18px; color: #000; opacity: 0.8; }
.step span { font-size: 28px; font-weight: 900; }


@keyframes popIn { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes panelUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes bounceDot { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }


.shake { animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both infinite; }
@keyframes shake { 10%, 90% { transform: translate3d(-2px, 0, 0); } 20%, 80% { transform: translate3d(4px, 0, 0); } 30%, 50%, 70% { transform: translate3d(-6px, 0, 0); } 40%, 60% { transform: translate3d(6px, 0, 0); } }
.mirror { border-color: var(--danger); box-shadow: 0 0 0 rgba(0,0,0,0); }
.delayed-ink { filter: blur(3px) contrast(1.2); opacity: 0.8; }


.mobile-fabs, .mobile-drawer { display: none; }

@media (max-width: 900px) {
  .menu-card { width: 90%; padding: 25px; }
  .game-title { font-size: 48px; }
  .lobby-card { width: 100%; }
  .lobby-body { grid-template-columns: 1fr; }
  .player-list { height: 150px; }
  
  .game-ui { padding: 10px; gap: 10px; height: 100vh; display: flex; flex-direction: column; }
  .header-bar { padding: 8px 12px; gap: 5px; flex-wrap: wrap; justify-content: space-around; }
  .h-group { min-width: auto; }
  .h-label { font-size: 9px; }
  .h-val { font-size: 16px; }
  
  .game-layout { flex-direction: column; gap: 0; overflow: visible; }
  .side-panel { display: none !important; } 
  
  .canvas-wrapper { 
    border-width: 0; border-radius: 0; 
    flex: 1; height: auto; 
    box-shadow: none; margin: 0 -10px; width: calc(100% + 20px); 
  }
  
 
  .mobile-fabs {
    display: flex; flex-direction: column; gap: 12px;
    position: fixed; right: 15px; bottom: 20px; z-index: 1400;
  }
  .fab {
    width: 56px; height: 56px; border-radius: 50%; border: none;
    background: #1e1e2d; color: #fff; font-size: 24px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.4); cursor: pointer;
    border: 1px solid rgba(255,255,255,0.1); transition: 0.2s;
  }
  .fab:active { transform: scale(0.9); }
  .fab.open { background: var(--primary); color: #000; border-color: transparent; }
  
  
  .mobile-drawer {
    display: block; position: fixed; left: 0; right: 0; bottom: 0;
    background: #1e1e2d; border-radius: 20px 20px 0 0;
    box-shadow: 0 -5px 40px rgba(0,0,0,0.5); z-index: 1450;
    padding-bottom: env(safe-area-inset-bottom);
    animation: panelUp 0.3s ease;
  }
  .drawer-head { display: flex; justify-content: space-between; padding: 15px 20px; border-bottom: 1px solid rgba(255,255,255,0.1); }
  .drawer-close { background: none; border: none; color: #fff; font-size: 20px; }
  .drawer-body { padding: 20px; max-height: 50vh; overflow-y: auto; }
  
  #chat-box-mobile { height: 180px; background: rgba(0,0,0,0.3); border-radius: 8px; padding: 10px; overflow-y: auto; margin-bottom: 10px; color: #ddd; }
  #chat-input-mobile { padding: 12px; }
}


.btn-back-menu{ margin-top: 10px; padding: 16px 22px; width: min(520px, 90vw); background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.18); color:#fff; }
.btn-back-menu:hover{ background: rgba(255,255,255,0.12); }

/* --- NASIL OYNANIR BUTONU VE MODAL TASARIMI --- */

/* Menüdeki Buton Rengi (Mor/Violet tonu) */
.btn-howto {
  background: #6c5ce7; /* Modern Violet */
  color: #fff;
  border: 1px solid rgba(108, 92, 231, 0.4);
  box-shadow: 0 4px 15px rgba(108, 92, 231, 0.3);
}
.btn-howto:hover {
  background: #5f27cd;
  filter: brightness(1.1);
}

/* Kartın Kendisi - Biraz daha geniş */
.howto-card {
  width: 600px; /* Standart karttan biraz daha geniş */
  max-width: 95vw;
  background: rgba(30, 30, 45, 0.98); /* Biraz daha opak */
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0; /* İç paddingi sıfırlayıp aşağıda ayarlayacağız */
  overflow: hidden; /* Köşelerden taşmasın */
  display: flex;
  flex-direction: column;
}

/* Başlık Alanı */
.howto-header {
  background: linear-gradient(135deg, rgba(108, 92, 231, 0.2), transparent);
  padding: 30px 30px 10px 30px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.howto-subtitle {
  color: var(--secondary);
  font-size: 14px;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: 700;
  margin-top: -15px;
  margin-bottom: 10px;
  opacity: 0.8;
}

/* İçerik Gövdesi */
.howto-body {
  padding: 30px;
  text-align: left;
  max-height: 60vh;
  overflow-y: auto;
}

/* Scrollbar Tasarımı (Webkit) */
.howto-body::-webkit-scrollbar { width: 6px; }
.howto-body::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); }
.howto-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }

/* Liste Maddeleri (Step) */
.howto-step {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
  background: rgba(255, 255, 255, 0.03);
  padding: 15px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: transform 0.2s, background 0.2s;
}

.howto-step:hover {
  transform: translateX(5px);
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
}

/* Numara Balonu */
.step-badge {
  min-width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 900;
  color: #fff;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  margin-top: 5px; /* Metinle hizalamak için */
}

/* Metin Alanı */
.step-content {
  flex: 1;
}
.step-content h4 {
  margin: 0 0 5px 0;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
}
.step-content p {
  margin: 0;
  font-size: 14px;
  color: #ccc;
  line-height: 1.5;
}

/* Alt kısımdaki buton için padding ayarı */
.howto-card .menu-buttons {
  padding: 0 30px 30px 30px;
}
#howto-overlay {
  position: fixed;
  inset: 0;            /* Tüm ekranı kapla */
  z-index: 2200;       /* En üstte görünsün */
  display: flex;       /* Esnek kutu modeli */
  align-items: center; /* Dikey ortalama */
  justify-content: center; /* Yatay ortalama */
  background: rgba(0, 0, 0, 0.6); /* Arka planı hafif karartma */
  backdrop-filter: blur(5px); /* Arka planı flulaştırma (modern görünüm) */
}

.howto-card {
  width: 750px; /* Daha geniş ki yan yana sığsınlar */
  max-width: 95vw;
}

.howto-body {
  padding: 20px 30px;
}

/* 1-2-3 Adımları için düzen */
.steps-container {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 15px;
  margin-bottom: 20px;
}

.howto-step {
  display: flex;
  flex-direction: column; /* Mobilde alt alta, PC'de kutu gibi */
  align-items: center;
  text-align: center;
  background: rgba(255, 255, 255, 0.03);
  padding: 15px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  height: 100%;
}

.step-badge {
  margin: 0 0 10px 0; /* Badge'i yukarı al */
  width: 32px; height: 32px; font-size: 16px;
}

.step-content h4 { font-size: 15px; color: var(--primary); margin-bottom: 5px; }
.step-content p { font-size: 12px; color: #aaa; }


/* Ayraç (Divider) */
.howto-divider {
  display: flex; align-items: center; justify-content: center;
  margin: 20px 0;
  position: relative;
}
.howto-divider::before {
  content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: rgba(255,255,255,0.1); z-index: 1;
}
.howto-divider span {
  background: #1e1e2d; /* Arka plan rengiyle aynı olmalı */
  padding: 0 15px;
  position: relative; z-index: 2;
  font-size: 11px; font-weight: 800; color: var(--secondary); letter-spacing: 1px;
}


/* Alt Kısım: Grid Kurallar */
.rules-grid {
  display: grid;
  grid-template-columns: 1fr 1fr; /* İki sütun */
  gap: 15px;
}

/* Kutu Tasarımları */
.rule-box {
  background: rgba(0,0,0,0.2);
  border-radius: 10px;
  padding: 12px;
  border: 1px solid rgba(255,255,255,0.05);
  font-size: 13px;
}

/* Uyarı Kutusu (Tam genişlik) */
.warning-box {
  grid-column: 1 / -1; /* Tüm satırı kapla */
  display: flex; align-items: center; gap: 15px;
  background: rgba(239, 71, 111, 0.1);
  border-color: rgba(239, 71, 111, 0.3);
}
.warning-box .r-icon { font-size: 24px; }
.warning-box strong { display: block; color: var(--danger); font-size: 14px; margin-bottom: 2px; }
.warning-box span { color: #ddd; font-size: 12px; }

/* Puan Tablosu ve Sabotaj Kutusu Başlıkları */
.r-header {
  font-weight: 800; color: #fff; border-bottom: 1px solid rgba(255,255,255,0.1);
  padding-bottom: 8px; margin-bottom: 8px; font-size: 12px; letter-spacing: 0.5px;
}

/* Puan Satırları */
.score-row {
  display: flex; justify-content: space-between;
  margin-bottom: 6px; color: #ccc; font-size: 12px;
}
.score-row strong { color: var(--success); }

/* Sabotaj Detayları */
.sabotage-box p { margin: 0 0 8px; line-height: 1.3; color: #bbb; font-size: 12px; }
.highlight-win { color: var(--primary); font-weight: bold; }
.highlight-lose { color: var(--danger); font-weight: bold; }
.r-divider { height: 1px; background: rgba(255,255,255,0.05); margin: 8px 0; }
.tip-text { font-size: 11px; color: var(--secondary); font-style: italic; margin-top: 5px; opacity: 0.8; }

/* Mobil Uyumluluk */
@media (max-width: 700px) {
  .steps-container { grid-template-columns: 1fr; } /* Adımlar alt alta */
  .rules-grid { grid-template-columns: 1fr; } /* Kurallar alt alta */
  .howto-step { flex-direction: row; text-align: left; gap: 15px; } /* Mobilde yan yana ikon+yazı */
  .step-badge { margin: 0; }
}

/* --- MOBILE FIX: Lobby code actions layout (copy button under code) --- */
@media (max-width: 520px){
  .lobby-header{
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .lobby-info{
    width: 100%;
  }
  .lobby-actions{
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: stretch;
    justify-content: stretch;
  }

  /* Copy button goes below lobby code and spans full width */
  .lobby-actions .copy-btn{
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    gap: 10px;
  }

  /* Keep text visible on mobile for clarity */
  .lobby-actions .copy-btn .btn-text{
    display: inline;
  }

  /* Settings stays inside the same translucent header area (full width for easy tap) */
  .lobby-actions .lobby-settings-btn{
    width: 100%;
    white-space: nowrap;
  }
  .lobby-actions .lobby-settings-btn .btn-text{
    display: inline;
  }
}



/* --- MOBILE FIX: Header bar layout avoids center island (left/right aligned) --- */
@media (max-width: 900px){
  .header-bar{
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "painter timer"
      "word word"
      "round actions";
    gap: 10px;
    align-items: center;
  }

  /* Map existing groups to grid areas */
  .header-bar > .h-group:nth-child(1){ grid-area: painter; }
  .header-bar > .h-group.word-group{ grid-area: word; }
  .header-bar > .h-group.timer-group{ grid-area: timer; justify-self: end; text-align: right; }
  .header-bar > .h-group:nth-child(4){ grid-area: round; }

  .header-bar > .header-actions{
    grid-area: actions;
    justify-self: end;
  }

  /* Make the word box use full width and not collide with edges */
  .header-bar .word-box{
    width: 100%;
    text-align: left;
  }

  /* Slightly tighter label/value spacing on small screens */
  .header-bar .h-label{ font-size: 11px; }
  .header-bar .h-val{ font-size: 14px; }
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8); /* Yarı saydam siyah */
  display: flex;
  justify-content: center; /* Yatay ortala */
  align-items: center; /* Dikey ortala */
  z-index: 9999; /* Her şeyin üstünde olsun */
  backdrop-filter: blur(5px); /* Arkadaki oyunu bulanıklaştırır (isteğe bağlı) */
}

/* Kartın kendisi */
.modal-card {
  background-color: #2c3e50; /* Koyu gri/mavi oyun rengi */
  color: white;
  padding: 30px;
  border-radius: 15px;
  border: 2px solid #e74c3c; /* Kırmızı çerçeve (Dikkat çekmesi için) */
  text-align: center;
  width: 300px;
  box-shadow: 0 0 20px rgba(231, 76, 60, 0.5); /* Hafif parlama efekti */
  font-family: 'Arial', sans-serif; /* Oyunun fontunu buraya yaz */
  animation: popIn 0.3s ease-out;
}

/* Başlık ve Metin */
.modal-title {
  margin-top: 0;
  color: #e74c3c;
  font-size: 1.5rem;
}

.modal-text {
  font-size: 1rem;
  margin: 20px 0;
  line-height: 1.4;
}

/* Buton Tasarımı */
.modal-btn {
  background-color: #e74c3c;
  color: white;
  border: none;
  padding: 10px 25px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: bold;
  transition: transform 0.1s;
}

.modal-btn:hover {
  background-color: #c0392b;
  transform: scale(1.05);
}

/* Açılma Animasyonu */
@keyframes popIn {
  0% { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
