:root {	
	/* Nuove variabili per i gradienti HSL dei tier */
	--tier-s-gradient: linear-gradient(45deg, hsl(var(--tier-s-hue), 100%, 59%), hsl(var(--tier-s-hue), 100%, 53%));
	--tier-a-gradient: linear-gradient(45deg, hsl(var(--tier-a-hue), 100%, 48%), hsl(var(--tier-a-hue), 100%, 50%));
	--tier-b-gradient: linear-gradient(45deg, hsl(var(--tier-b-hue), 100%, 50%), hsl(var(--tier-b-hue), 100%, 53%));
	--tier-c-gradient: linear-gradient(45deg, hsl(var(--tier-c-hue), 100%, 50%), hsl(var(--tier-c-hue), 100%, 45%));
	--tier-d-gradient: linear-gradient(45deg, hsl(var(--tier-d-hue), 100%, 58%), hsl(var(--tier-d-hue), 100%, 50%));
}

* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

body {
	font-family: 'Arial', sans-serif;
	color: var(--fg);
	min-height: 100vh;
	padding: 20px;
	
	background: var(--bg-gradient);
}

.bg-pattern{
	--s: 96px; /* control the size*/
	
	--_g: 0 120deg,#0000 0;
	background:
	conic-gradient(at calc(250%/3) calc(100%/3),var(--c3) var(--_g)),
	conic-gradient(from -120deg at calc(50%/3) calc(100%/3),var(--c2) var(--_g)),
	conic-gradient(from 120deg at calc(100%/3) calc(250%/3),var(--c1) var(--_g)),
	conic-gradient(from 120deg at calc(200%/3) calc(250%/3),var(--c1) var(--_g)),
	conic-gradient(from -180deg at calc(100%/3) 50%,var(--c2) 60deg,var(--c1) var(--_g)),
	conic-gradient(from 60deg at calc(200%/3) 50%,var(--c1) 60deg,var(--c3) var(--_g)),
	conic-gradient(from -60deg at 50% calc(100%/3),var(--c1) 120deg,var(--c2) 0 240deg,var(--c3) 0);
	background-size: calc(var(--s)*sqrt(3)) var(--s);
}

a {
	color: var(--link);
	text-decoration: none;
}

a:hover {
	color: var(--link-hover);
	text-decoration: underline;
}

p{
	color: var(--fg);
}

.container {
	max-width: 1400px;
	margin: 0 auto;
	background: var(--container-bg);
	border-radius: 20px;
	padding: 20px;
	box-shadow: 0 20px 40px rgba(0,0,0,0.5);
	margin-bottom: 300px;
}

.header {
	text-align: center;
	margin-bottom: 30px;
}

.header h1 {
	color: var(--h1);
	font-size: 2.5rem;
	margin-bottom: 10px;
	text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.controls {
	display: flex;
	gap: 15px;
	margin-bottom: 30px;
	flex-wrap: wrap;
	align-items: center;
}

.input-group {
	display: flex;
	gap: 10px;
	width: 100%;
	align-items: center;
}

.json-controls {
	display: flex;
	justify-content: center;
	align-items: center;
}

#itemName {
	flex: 1;
	min-width: 0;
}

input[type="text"] {
	padding: 12px 16px;
	border: 2px solid var(--border);
	border-radius: 25px;
	font-size: 14px;
	outline: none;
	background-color: var(--input-bg);
	color: var(--fg);
}

input[type="text"]:focus {
	border-color: var(--selected);
}

.btn {
	background: var(--btn-bg);
	color: white;
	border: none;
	padding: 12px 24px;
	border-radius: 25px;
	cursor: pointer;
	font-size: 14px;
	font-weight: bold;
	text-transform: uppercase;
	letter-spacing: 1px;
}

.btn:hover {
	opacity: 0.9;
}

.btn:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.loading {
	display: inline-block;
	width: 16px;
	height: 16px;
	border: 2px solid var(--contrast);
	border-radius: 50%;
	border-top-color: transparent;
	animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
	to { transform: rotate(360deg); }
}

/* =======================================
          TIERLIST CON CSS GRID
   ======================================= */
.tierlist {
	display: grid;
	grid-template-columns: max-content 1fr;
	gap: 15px 0;
}

.tier-row {
	display: contents;
}

.tier-label {
	padding: 0 40px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: bold;
	font-size: 2rem;
	color: white;
	text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
	cursor: pointer;
	border-radius: 12px 0 0 12px;
}

.tier-s { background: var(--tier-s-gradient); }
.tier-a { background: var(--tier-a-gradient); }
.tier-b { background: var(--tier-b-gradient); }
.tier-c { background: var(--tier-c-gradient); }
.tier-d { background: var(--tier-d-gradient); }

.tier-content {
	background: var(--tier-bg);
	padding: 15px;
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
	align-items: center;
	min-height: 120px;
	border: 2px dashed var(--border);
	border-radius: 0 12px 12px 0;
}

/* =======================================
          ITEMS POOL
   ======================================= */
.items-pool {
	background: var(--container-bg);
	border-radius: 12px;
	margin-bottom: 10px;
	padding: 20px;
	border: 2px dashed var(--border);
	box-shadow: inset 0 2px 10px rgba(0,0,0,0.2);
	width: 100%;
	display: flex;
	flex-direction: column;
}

.items-pool h3 {
	margin-bottom: 15px;
	color: var(--fg);
	font-size: 1.5rem;
}

.items-container {
	display: flex;
	gap: 15px;
	flex-wrap: wrap;
	flex: 1;
	min-height: 160px;
	width: 100%;
}

#drop-area {
	border: 2px dashed #888;
	border-radius: 10px;
	padding: 20px;
	text-align: center;
	cursor: pointer;
	margin-bottom: 20px;
	background-color: var(--container-bg);
	color: #ccc;
}

#drop-area:hover, #drop-area.drag-over-input {
	border-color: var(--selected);
	background-color: var(--selected-bg);
}

#file-input {
	display: none;
}

.tier-item {
	width: calc(264px / 2.5);
	height: auto;
	border-radius: 12px;
	cursor: move;
	position: relative;
	box-shadow: 0 4px 12px rgba(0,0,0,0.3);
	overflow: visible;
	transition: width 0.4s ease-in-out,
	height 0.4s ease-in-out,
	box-shadow 0.4s ease-in-out;
}

.tier-item:hover {
	box-shadow: 0 6px 18px rgba(0,0,0,0.45);
	width: calc(600px/2.5);
	transition-delay: 1s;
}

.tier-item img {
	width: 100%;
	height: auto;
	object-fit: cover;
	display: block;
	border-radius: 8px 8px 0 0;
}

.tier-item .item-title {
	background: var(--item-title-bg);
	color: var(--contrast);
	padding: 4px 6px;
	font-size: 12px;
	text-align: center;
	border-radius: 0 0 8px 8px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.tier-item .delete-button {
	position: absolute;
	top: -10px;
	right: -10px;
	z-index: 10;
	background-color: var(--delete-bg);
	color: var(--contrast);
	border: none;
	border-radius: 50%;
	width: 24px;
	height: 24px;
	cursor: pointer;
}

.ui-sortable-helper {
	z-index: 1000 !important;
	transform: rotate(5deg) scale(1.1);
}

.ui-sortable-placeholder {
	background: hsla(232, 70%, 78%, 0.2); /* Sostituito con un colore derivato da --selected */
	border: 2px dashed var(--selected);
	border-radius: 8px;
}

.delete-btn {
	position: absolute;
	top: -10px;
	right: -10px;
	background: var(--delete-bg);
	color: var(--contrast);
	border: none;
	border-radius: 50%;
	width: 24px;
	height: 24px;
	font-size: 14px;
	font-weight: bold;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 100;
	box-shadow: 0 2px 6px rgba(0,0,0,0.3);
	transition: all 0.2s ease;
}

.tier-item .delete-btn {
	display: flex;
	opacity: 0;
	transition: opacity 0.3s ease 2s;
}

.tier-item:hover .delete-btn {
	opacity: 1;
	transition: opacity 0s ease;
}

.delete-btn:hover {
	background: var(--delete-hover);
	transform: scale(1.1);
}

.error-message {
	background: var(--error);
	color: var(--contrast);
	padding: 10px;
	border-radius: 5px;
	margin: 10px 0;
	display: none;
}

/* =======================================
          ZOOM SLIDER
   ======================================= */
.zoom-slider {
	background: var(--container-bg);
	border-radius: 12px;
	margin-bottom: 30px;
	padding: 20px;
	border: 2px dashed var(--border);
	box-shadow: inset 0 2px 10px rgba(0,0,0,0.2);
	width: 100%;
	display: flex;
	align-items: center;
	gap: 15px;
}

.zoom-slider label {
	font-weight: bold;
	color: var(--fg);
	font-size: 16px;
	min-width: 50px;
}

#widthSlider {
	flex: 1;
	height: 8px;
	border-radius: 4px;
	background: var(--border);
	outline: none;
	opacity: 0.7;
	transition: opacity 0.2s;
	cursor: pointer;
	max-width: 300px;
}

#widthSlider:hover {
	opacity: 1;
}

#widthSlider::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	background: var(--btn-bg);
	cursor: pointer;
	box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

#widthSlider::-moz-range-thumb {
	width: 20px;
	height: 20px;
	border-radius: 50%;
	background: var(--btn-bg);
	cursor: pointer;
	border: none;
	box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

#widthValue {
	font-weight: bold;
	color: var(--selected);
	font-size: 16px;
	min-width: 40px;
	text-align: right;
}