:root {
  --hex-border: #8a683f;
  --hex-highlight: #2e8b57;
  --hex-radius: 56px;
  --hex-width: calc(var(--hex-radius) * 2);
  --hex-height: calc(var(--hex-radius) * 1.732);
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f6e7c3;
}

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #f6e7c3;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loading-overlay.loading-overlay--hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.loading-spinner svg {
  width: 60px;
  height: 60px;
  color: #654321;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.loading-spinner p {
  margin: 0;
  font-size: 1rem;
  color: #654321;
  font-weight: 500;
}

#status {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 8px 16px;
  font-size: 1.1rem;
  color: #654321;
  background: rgba(255, 253, 246, 0.95);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.mode-selector {
  position: fixed;
  top: 74px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  background: rgba(255, 253, 246, 0.98);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  z-index: 300;
  transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
  transform-origin: top right;
  min-width: 200px;
}

.mode-selector--hidden {
  opacity: 0;
  visibility: hidden;
  transform: scale(0.95) translateY(-10px);
  pointer-events: none;
}

.menu-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu-section--hidden {
  display: none;
}

.menu-section__label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #8a623f;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0;
  padding: 0 4px;
}

.menu-section__buttons {
  display: flex;
  gap: 4px;
  background: rgba(198, 155, 90, 0.15);
  border-radius: 8px;
  padding: 4px;
}

.mode-btn,
.lang-btn {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #654321;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  text-align: center;
}

.mode-btn:hover,
.lang-btn:hover {
  background: rgba(255, 255, 255, 0.5);
}

.mode-btn--active,
.lang-btn--active {
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.mode-btn--disabled,
.mode-btn--disabled:hover {
  background: transparent;
  opacity: 0.45;
  cursor: not-allowed;
}

.piece-select-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  height: 44px;
}

.piece-icon {
  height: 100%;
  width: auto;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.2));
  transition: transform 0.2s ease;
}

.piece-select-btn:hover .piece-icon {
  transform: scale(1.1);
}

.difficulty-control__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(198, 155, 90, 0.15);
  border-radius: 8px;
  padding: 4px;
}

.difficulty-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.7);
  color: #654321;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
  flex-shrink: 0;
}

.difficulty-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.95);
}

.difficulty-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.difficulty-btn svg {
  width: 16px;
  height: 16px;
}

.difficulty-control__value {
  flex: 1;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: #654321;
  min-width: 80px;
}

#ai-difficulty {
  width: 100%;
  margin-top: 8px;
  accent-color: #c69b5a;
}

.mode-btn--active,
.lang-btn--active {
  background: rgba(198, 155, 90, 0.4);
  color: #3d2817;
}

.ai-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 253, 246, 0.95);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  z-index: 10;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.ai-loading-overlay.ai-loading-overlay--hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.ai-loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px;
  text-align: center;
}

.ai-loading-spinner svg {
  width: 40px;
  height: 40px;
  color: #654321;
  animation: spin 1s linear infinite;
}

.ai-loading-spinner p {
  margin: 0;
  font-size: 0.85rem;
  color: #654321;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ai-loading-progress {
  font-size: 0.9rem;
}

.board {
  position: relative;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(255, 248, 230, 0.6), rgba(198, 155, 90, 0.4)),
    url('assets/img/bg-wood.webp') center/cover;
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.25), inset 0 0 0 10px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

.board::after {
	content: "";
	position: absolute;
	inset: 18px;
	border: 4px solid rgba(0, 0, 0, 0.12);
	border-radius: 12px;
	pointer-events: none;
}

.board.board--finished {
	filter: grayscale(0.8) brightness(0.6);
}

.gunzi-logo {
  position: absolute;
  bottom: 15px;
  right: 20px;
  width: clamp(42px, 12vw, 78px);
  height: auto;
  opacity: 0.6;
  pointer-events: none;
  z-index: 0;
}

.status--winner {
  color: #d9534f;
  font-weight: 700;
  font-size: 1.25rem;
  background: rgba(255, 253, 246, 1) !important;
  border: 2px solid #d9534f;
  box-shadow: 0 4px 16px rgba(217, 83, 79, 0.3) !important;
  animation: pulse-winner 2s infinite;
}

@keyframes pulse-winner {
  0% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.05); }
  100% { transform: translateX(-50%) scale(1); }
}

.hex {
	position: absolute;
	width: var(--hex-width);
	height: var(--hex-height);
	clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
	border: none;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.15s ease, box-shadow 0.15s ease;
	background-position: center;
	background-size: cover;
}

.hex--light {
	background-image: url('assets/svg/hex-piece-light.svg');
}

.hex--dark {
  background-image: url('assets/svg/hex-piece-dark.svg');
}.hex:hover {
	transform: translateY(-2px);
	box-shadow: 0 8px 16px rgba(60, 30, 5, 0.24);
}

.hex--highlight {
	box-shadow: 0 0 0 6px rgba(46, 139, 87, 0.35), 0 10px 22px rgba(0, 0, 0, 0.25);
}

.hex--highlight::after {
	content: "";
	position: absolute;
	inset: 8%;
	clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
	background: rgba(46, 139, 87, 0.28);
	pointer-events: none;
}

.hex.is-blocked {
	cursor: not-allowed;
}

.piece {
	width: calc(var(--hex-width) * 0.72);
	height: calc(var(--hex-height) * 0.78);
	display: flex;
	justify-content: center;
	align-items: center;
	position: relative;
	cursor: pointer;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
	outline: none;
}

.piece:focus-visible {
	outline: 2px solid rgba(46, 139, 87, 0.6);
	outline-offset: 2px;
}

.piece__icon {
	width: 100%;
	height: 100%;
	object-fit: contain;
	display: block;
	pointer-events: none;
}

.piece--selected {
	transform: scale(1.08) translateY(-3px);
	filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.4)) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
	z-index: 10;
}

.piece--promoted {
  display: none;
}

/* Action buttons (reset, undo, redo) */
.action-btn {
  position: fixed;
  width: 44px;
  height: 44px;
  padding: 10px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 253, 246, 0.95);
  color: #654321;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
  z-index: 140;
}

.action-btn:hover:not(:disabled) {
  background: rgba(255, 253, 246, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.action-btn:disabled,
.action-btn--disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.action-btn svg {
  width: 100%;
  height: 100%;
  display: block;
}

.reset-icon {
  top: 236px;
  right: 20px;
}

.reset-icon:hover:not(:disabled) {
  transform: rotate(180deg);
}

.undo-btn {
  top: 128px;
  right: 20px;
}

.redo-btn {
  top: 182px;
  right: 20px;
}

.ff-login-disabled .undo-btn {
  top: 74px;
}

.ff-login-disabled .redo-btn {
  top: 128px;
}

.ff-login-disabled .reset-icon {
  top: 182px;
}

.menu-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  padding: 10px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 253, 246, 0.95);
  color: #654321;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
  z-index: 100;
}

.action-btn--hidden {
  display: none !important;
}

.menu-toggle:hover {
  background: rgba(255, 253, 246, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.menu-toggle svg {
  width: 100%;
  height: 100%;
  display: block;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.status-mode {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: bold;
  text-transform: uppercase;
  vertical-align: middle;
  letter-spacing: 0.5px;
}

.status-mode--slowgo {
  background-color: #e6dcc3;
  color: #654321;
  border: 1px solid rgba(101, 67, 33, 0.2);
}

.status-mode--gogo {
  background-color: #d97706;
  color: #fff;
  border: 1px solid #b45309;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
/* Auth floating button + modal */
.account-toggle {
  position: fixed;
  /* Stack under the hamburger by default */
  top: 74px;
  right: 20px;
  width: 44px;
  height: 44px;
  padding: 10px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 253, 246, 0.95);
  color: #654321;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
  z-index: 102;
}

.account-toggle svg {
  width: 100%;
  height: 100%;
}

.account-toggle:hover {
  background: rgba(255, 253, 246, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.account-panel {
  position: fixed;
  /* Open below the stacked hamburger + profile buttons */
  top: 128px;
  right: 20px;
  padding: 16px;
  background: rgba(255, 253, 246, 0.98);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  z-index: 200;
  width: min(360px, calc(100vw - 24px));
  min-width: 0;
  transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
  transform-origin: top right;
}

.account-panel--hidden {
  opacity: 0;
  visibility: hidden;
  transform: scale(0.95) translateY(-10px);
  pointer-events: none;
}

.account-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.account-panel__title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #5b3d24;
}

.account-panel__row {
  display: flex;
  gap: 10px;
  margin: 8px 0;
  flex-wrap: wrap;
}

.account-panel__row > .account-btn {
  flex: 1 1 auto;
}

.account-panel__row--split {
  justify-content: flex-end;
}

.account-label {
  margin: 0 0 6px;
  font-size: 13px;
  color: #6c4b2b;
}

.account-inline {
  display: flex;
  gap: 0;
  align-items: center;
}

#auth-save-profile {
  margin-left: 8px;
}

.account-input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #fffaf2;
  color: #3b220f;
}

.account-input:focus {
  outline: none;
  border-color: rgba(101, 67, 33, 0.35);
  box-shadow: 0 0 0 2px rgba(101, 67, 33, 0.12);
}

.account-input--with-prefix {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  margin-left: -1px;
}

.account-input-prefix {
  padding: 10px 0 10px 12px;
  border-radius: 12px 0 0 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-right: none;
  background: #fffaf2;
  color: #6c4b2b;
  font-size: 14px;
}

.account-details {
  margin-top: 12px;
}

.account-summary {
  cursor: pointer;
  font-size: 13px;
  color: #6c4b2b;
  padding: 6px 0;
}

.account-summary:hover {
  color: #3b220f;
}

.account-password-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.account-btn {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: rgba(255, 255, 255, 0.6);
  color: #3b220f;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  line-height: 1;
}

.account-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.8);
}

.account-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.account-btn--primary {
  background: #e4c6a4;
  border: none;
  color: #3b220f;
}

.account-btn--ghost {
  background: transparent;
}

.account-btn--danger {
  background: rgba(220, 53, 69, 0.12);
  border: 1px solid rgba(220, 53, 69, 0.5);
  color: #8b1f2b;
}

.account-danger {
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  padding-top: 10px;
  margin-top: 6px;
}

.account-help {
  margin: 4px 0 0;
  font-size: 12px;
  color: #6c4b2b;
}

.account-footnote {
  margin: 8px 0 0;
  font-size: 12px;
  color: #6c4b2b;
}

.account-protected {
  margin-top: 8px;
}

.account-hidden {
  display: none !important;
}

/* Promotion Crown */
.crown-marker,
.crown-promoted {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 70%;
  height: 70%;
  pointer-events: none;
}

.crown-marker {
  opacity: 0.15;
  z-index: 0;
  mix-blend-mode: multiply;
}

.crown-promoted {
  opacity: 0;
  z-index: 20;
  transition: opacity 0.5s ease;
}

.crown-promoted.is-active {
  opacity: 1;
}

.crown--hidden {
  display: none;
}

.crown--rotated {
  transform: translate(-50%, -50%) rotate(180deg);
}

@media (max-width: 640px) {
	:root {
		--hex-radius: 44px;
	}

	.action-btn {
		width: 40px;
		height: 40px;
		padding: 8px;
	}

  .menu-toggle {
    /* Hamburger stays at the top-right */
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    padding: 8px;
    z-index: 160;
  }

  /* Account button shares the .menu-toggle class; override after .menu-toggle */
  #account-toggle {
    top: 62px;
    right: 12px;
    width: 40px;
    height: 40px;
    padding: 8px;
    z-index: 159;
  }

  .reset-icon {
    top: 212px;
		right: 12px;
	}

	.undo-btn {
    top: 112px;
		right: 12px;
	}

	.redo-btn {
    top: 162px;
		right: 12px;
	}

  .ff-login-disabled .undo-btn {
    top: 62px;
  }

  .ff-login-disabled .redo-btn {
    top: 112px;
  }

  .ff-login-disabled .reset-icon {
    top: 162px;
  }

	#status {
		top: 12px;
		font-size: 0.95rem;
		padding: 6px 12px;
	}

	.mode-selector {
    /* Open directly beneath the hamburger */
    top: 62px;
		right: 12px;
	}

.mode-btn {
 font-size: 0.85rem;
 padding: 8px 12px;
}
}
