* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: linear-gradient(160deg, #1b2a4a 0%, #233a63 55%, #1b2a4a 100%);
  color: #eaf2ff;
  overflow: hidden;
  position: relative;
}

#game {
  position: fixed;
  inset: 0;
  margin: auto;
  display: block;
  /* JS (resize) canvas.style.width/height ve canvas.width/height (DPR dahil)
     ayarlar; box boyutu JS'in hesapladigi CSS boyutuna esit olmasi gerekir
     ki cizim yuzeyiyle (drawing surface) birebir orantilanip keskin kalsin. */
  width: 400px;
  height: 600px;
  background: #70c5ce;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.hidden {
  display: none !important;
}

/* ---------- Oyuna giris ---------- */
.entry {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  overflow-y: auto;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 218, 78, 0.2), transparent 34%),
    rgba(7, 17, 36, 0.78);
  backdrop-filter: blur(7px);
}

.entry.hidden {
  display: none;
}

.entry-panel {
  position: relative;
  width: min(420px, 100%);
  padding: 30px;
  overflow: hidden;
  color: #2c2c2c;
  background: linear-gradient(155deg, #fffdf7 0%, #f3ead6 100%);
  border: 2px solid #d3a13d;
  border-radius: 22px 22px 14px 14px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.55), inset 0 1px rgba(255, 255, 255, 0.9);
}

.entry-panel::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 6px;
  background: linear-gradient(90deg, #b65b18, #ffd94d 48%, #b65b18);
}

.entry-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  color: #9a5718;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.18em;
}

.entry-brand img {
  width: 27px;
  height: 27px;
  object-fit: contain;
}

.entry-panel h1 {
  margin-bottom: 8px;
  color: #713914;
  font-size: clamp(25px, 7vw, 34px);
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.entry-copy {
  margin-bottom: 22px;
  color: #6f6255;
  font-size: 14px;
  line-height: 1.55;
}

.entry-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px 10px;
}

.entry-form label {
  color: #70431e;
  font-size: 12px;
  font-weight: 800;
}

.entry-form input {
  width: 100%;
  min-width: 0;
  padding: 11px 12px;
  color: #2c2c2c;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(112, 67, 30, 0.28);
  border-radius: 10px;
  font: inherit;
  outline: none;
}

.entry-form input:focus {
  border-color: #d98e04;
  box-shadow: 0 0 0 3px rgba(217, 142, 4, 0.18);
}

.entry-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 8px;
}

.entry-error {
  min-height: 20px;
  margin-top: 9px;
  color: #a5241e;
  font-size: 12.5px;
  font-weight: 700;
  text-align: center;
}

.entry-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 3px 0 12px;
  color: #9b8d7d;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.entry-divider::before,
.entry-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(112, 67, 30, 0.18);
}

.menu-btn.guest {
  color: #70431e;
  background: transparent;
  border-color: rgba(112, 67, 30, 0.32);
}

.entry-note {
  margin-top: 10px;
  color: #8a7c6c;
  font-size: 11.5px;
  line-height: 1.4;
  text-align: center;
}

.menu-btn:disabled {
  cursor: wait;
  opacity: 0.58;
}

@media (max-width: 520px) {
  .entry {
    align-items: end;
    padding: 10px;
  }

  .entry-panel {
    padding: 25px 20px 20px;
    border-radius: 20px 20px 10px 10px;
  }

}

.hint {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  font-size: 13px;
  color: #a9c1e8;
  letter-spacing: 0.02em;
  background: rgba(10, 22, 45, 0.55);
  padding: 6px 14px;
  border-radius: 999px;
  white-space: nowrap;
  pointer-events: none;
}

.hint kbd {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-bottom-width: 2px;
  background: rgba(255, 255, 255, 0.08);
  font-family: inherit;
  font-size: 12px;
}

/* ---------- Ayarlar menusu ---------- */
#settings-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(10, 22, 45, 0.55);
  color: #eaf2ff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  z-index: 20;
}

#settings-btn:hover {
  background: rgba(30, 55, 105, 0.75);
  transform: rotate(30deg);
}

.settings {
  position: fixed;
  inset: 0;
  background: rgba(8, 14, 30, 0.65);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 20;
}

.settings.hidden {
  display: none;
}

.settings-panel {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  overflow: hidden;
  background: linear-gradient(180deg, #ffffff 0%, #f2ecdd 100%);
  color: #2c2c2c;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  min-height: 68px;
  padding: 14px clamp(18px, 4vw, 54px);
  background: rgba(255, 255, 255, 0.72);
  border-bottom: 1px solid rgba(140, 74, 31, 0.14);
}

.settings-head h2 {
  font-size: clamp(20px, 3vw, 28px);
  color: #8c4a1f;
  letter-spacing: 0.02em;
}

.panel-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.06);
  color: #5a5a5a;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease;
}

.panel-close:hover {
  background: rgba(0, 0, 0, 0.14);
}

.settings-tabs {
  display: flex;
  gap: 8px;
  width: min(1000px, 100%);
  margin: 0 auto;
  padding: 16px 18px 12px;
  flex-wrap: wrap;
}

.tab {
  flex: 1;
  padding: 9px 10px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.04);
  color: #5a5a5a;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.tab.active {
  background: #8c4a1f;
  border-color: #6d3a17;
  color: #fff;
}

.settings-body {
  flex: 1 1 auto;
  width: min(1000px, 100%);
  margin: 0 auto;
  padding: 12px 18px 24px;
  overflow-y: auto;
}

.inventory-body {
  padding-top: 24px;
}

.inventory-body .sound-settings {
  width: min(720px, 100%);
  margin: 0 auto;
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 6px;
  border: 2px solid rgba(0, 0, 0, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.option:hover {
  background: rgba(255, 255, 255, 0.95);
}

.option.selected {
  border-color: #d98e04;
  background: #fff7e2;
  box-shadow: 0 0 0 2px rgba(217, 142, 4, 0.25);
}

.option canvas {
  width: 56px;
  height: 56px;
  display: block;
}

.option .name {
  font-size: 12px;
  font-weight: 600;
  color: #4a4a4a;
  text-align: center;
  line-height: 1.25;
}

.option.selected .name {
  color: #8c4a1f;
}

.option .sub {
  font-size: 11px;
  font-weight: 500;
  color: #8a8a8a;
  text-align: center;
  line-height: 1.3;
}

.option.selected .sub {
  color: #a06a35;
}

.settings-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 18px 16px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.settings-info {
  font-size: 12.5px;
  color: #6a6a6a;
}

.gold-icon {
  display: inline-block;
  width: 1.05em;
  height: 1.05em;
  margin: 0 0.18em;
  object-fit: contain;
  vertical-align: -0.18em;
  filter: drop-shadow(0 1px 1px rgba(109, 58, 23, 0.25));
}

#settings-reset {
  padding: 7px 14px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.05);
  color: #5a5a5a;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

#settings-reset:hover {
  background: rgba(0, 0, 0, 0.12);
}

/* ---------- Duraklatma menusu (pause) ---------- */
.pause-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: min(620px, 100%);
  margin: 0 auto;
  gap: 10px;
  padding: 24px 18px;
  overflow-y: auto;
}

.pause-body.hidden {
  display: none;
}

.menu-btn {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.05);
  color: #4a4a4a;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
}

.menu-btn:hover {
  background: rgba(0, 0, 0, 0.12);
}

.menu-btn.primary {
  background: #8c4a1f;
  border-color: #6d3a17;
  color: #fff;
}

.menu-btn.primary:hover {
  background: #74401b;
}

.menu-btn.small {
  width: auto;
  font-size: 13px;
  padding: 8px 12px;
}

.room-current {
  font-size: 13px;
  font-weight: 600;
  color: #8c4a1f;
  text-align: center;
}

.rooms-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: min(45vh, 480px);
  overflow-y: auto;
}

.room-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border: 2px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  font-weight: 600;
  color: #4a4a4a;
}

.room-row.active {
  border-color: #d98e04;
  background: #fff7e2;
  color: #8c4a1f;
}

.rooms-create {
  display: flex;
  gap: 8px;
}

#room-name {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
}

#net-name,
#net-roomname,
#net-pass,
#net-join-id,
#net-join-pass {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.85);
  color: #2c2c2c;
}

#net-join-id {
  font-family: ui-monospace, Consolas, monospace;
}

.net-ping {
  font-size: 12.5px;
  font-weight: 700;
  color: #8c4a1f;
  text-align: center;
}

.auth-row {
  display: flex;
  gap: 8px;
}

.auth-row input {
  flex: 1;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.85);
  color: #2c2c2c;
}

.pips {
  color: #d98e04;
  letter-spacing: 2px;
  font-size: 14px;
  font-weight: 700;
}

.up-bal {
  font-size: 14px;
  font-weight: 700;
  color: #8c4a1f;
  text-align: center;
}

.up-account {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: #4a4a4a;
}

.net-error {
  min-height: 18px;
  font-size: 13px;
  font-weight: 600;
  color: #b3261e;
  text-align: center;
}

.room-ping {
  margin-left: auto;
  font-size: 12px;
  font-weight: 700;
  color: #8c4a1f;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#net-room-id {
  font-family: ui-monospace, Consolas, monospace;
  letter-spacing: 0.05em;
}

.rooms-note {
  font-size: 12px;
  color: #8a8a8a;
  text-align: center;
}

/* ---------- Ses ayarlari ---------- */
.sound-settings {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sound-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border: 2px solid rgba(0, 0, 0, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
}

.sound-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
  color: #4a4a4a;
}

.sound-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #5a5a5a;
  cursor: pointer;
  user-select: none;
}

.sound-toggle input {
  width: 18px;
  height: 18px;
  accent-color: #8c4a1f;
  cursor: pointer;
}

.sound-slider {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sound-slider input[type='range'] {
  flex: 1;
  min-width: 0;
  accent-color: #d98e04;
  cursor: pointer;
}

.sound-slider input[type='range']:disabled {
  opacity: 0.35;
  cursor: default;
}

.sound-val {
  min-width: 44px;
  text-align: right;
  font-size: 13px;
  font-weight: 700;
  color: #8c4a1f;
  font-variant-numeric: tabular-nums;
}

.sound-note {
  font-size: 12px;
  color: #8a8a8a;
  text-align: center;
  line-height: 1.5;
}

.sound-sub {
  font-size: 13px;
  font-weight: 700;
  color: #8c4a1f;
  margin: 2px 2px -4px;
}

/* ---------- Arkadaslar ---------- */
.friends-body {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(320px, 1.2fr);
  align-content: start;
  gap: 16px;
  padding-top: 24px;
}

.friends-card {
  padding: 18px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(140, 74, 31, 0.16);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(80, 46, 18, 0.08);
}

.friends-card h3 {
  color: #70431e;
  font-size: 15px;
}

.friends-list-card {
  grid-column: 1 / -1;
}

.friend-add {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.friend-add input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  color: #2c2c2c;
  background: #fff;
  border: 1px solid rgba(112, 67, 30, 0.25);
  border-radius: 9px;
  font: inherit;
}

.friends-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.friend-count {
  min-width: 24px;
  padding: 3px 7px;
  color: #fff;
  background: #d98e04;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.friend-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.friend-row {
  display: grid;
  grid-template-columns: auto minmax(100px, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  background: rgba(255, 250, 239, 0.9);
  border: 1px solid rgba(112, 67, 30, 0.14);
  border-radius: 11px;
}

.friend-row.invite-row {
  grid-template-columns: minmax(120px, 1fr) auto;
  border-color: rgba(217, 142, 4, 0.38);
  background: #fff8e7;
}

.friend-avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: #fff;
  background: linear-gradient(145deg, #d98e04, #8c4a1f);
  border-radius: 50%;
  font-size: 16px;
  font-weight: 900;
}

.friend-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 3px;
}

.friend-info strong {
  overflow: hidden;
  color: #3f3024;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.friend-info span {
  color: #837568;
  font-size: 12px;
}

.friend-info .friend-online {
  color: #24864d;
  font-weight: 700;
}

.friend-info .friend-offline {
  color: #8a8a8a;
}

.friend-actions {
  display: flex;
  gap: 7px;
}

.menu-btn.danger {
  color: #a5241e;
  border-color: rgba(165, 36, 30, 0.22);
}

.friend-empty {
  padding: 18px 12px;
  color: #8a7c6c;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

@media (max-width: 680px) {
  .friends-body {
    grid-template-columns: 1fr;
  }

  .friends-list-card {
    grid-column: auto;
  }

  .friend-row,
  .friend-row.invite-row {
    grid-template-columns: auto minmax(90px, 1fr);
  }

  .friend-row.invite-row .friend-info {
    grid-column: 1 / -1;
  }

  .friend-actions {
    grid-column: 1 / -1;
  }

  .friend-actions .menu-btn {
    flex: 1;
  }
}

.up-bal .gold-icon {
  width: 1.2em;
  height: 1.2em;
}
